Premium
BASH Snippets.

Curated list of production-ready BASH scripts and coding solutions.

BASH

Efficient Remote File Deployment with Rsync

Automate the deployment of your static website files or build artifacts to a remote server using rsync, ensuring only changed files are transferred efficiently.

View Snippet →
BASH

Extract Data from JSON API Responses with jq

Learn how to quickly parse and extract specific data fields from JSON responses returned by web APIs using the powerful command-line JSON processor `jq`.

View Snippet →
BASH

Automated Cleanup of Old Log Files

Implement a bash script to automatically delete log files older than a specified number of days, helping to manage disk space and maintain server hygiene.

View Snippet →
BASH

Perform Basic HTTP Health Check with Curl

Create a bash script to perform basic health checks on web services or URLs using `curl`, verifying HTTP status codes and response times for service availability.

View Snippet →
BASH

Manage Project-Specific Environment Variables

Learn to load and export project-specific environment variables from a `.env` file into your current shell session, essential for managing configurations in development.

View Snippet →
BASH

Parse and Extract Data from JSON Files with jq

Learn to efficiently parse and extract specific data from JSON files and API responses using the powerful `jq` command-line JSON processor in bash scripts.

View Snippet →
BASH

Automate Local Domain Management in /etc/hosts

Streamline your web development workflow by automating the addition and removal of custom local domain entries in your `/etc/hosts` file using a simple bash script.

View Snippet →
BASH

Configure HTTP Strict Transport Security (HSTS) in Nginx

Enhance web security by configuring HSTS in Nginx, forcing browsers to communicate with your server exclusively over HTTPS and preventing downgrade attacks.

View Snippet →
BASH

Create and Navigate to New Project Directory

Automate the creation of a new project directory structure and immediately navigate into it, streamlining development setup for web projects.

View Snippet →
BASH

Real-time Log File Monitoring for Keywords

Monitor a specified log file continuously for the occurrence of specific keywords, useful for real-time debugging and error detection in web server logs.

View Snippet →
BASH

Automate Timestamped Directory Backup

Create a compressed, timestamped archive of a specified directory, ideal for regular backups of web project files, databases, or configurations.

View Snippet →
BASH

Monitor and Restart a System Service

Automatically check if a specified systemd service is active and restart it if it's not, ensuring continuous availability for web applications or databases.

View Snippet →