Premium
BASH Snippets.

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

BASH

Generate Basic Project Structure

Automate the creation of a common web project directory structure with subdirectories for `src`, `public`, `assets`, `dist`, and configuration files.

View Snippet →
BASH

Automate Git Commit and Push

Simplify common Git workflows by automatically adding all changes, committing with a predefined message or a provided one, and pushing to the current branch.

View Snippet →
BASH

Start Local Web Server & Open Browser

Launch a basic HTTP server using Python's `http.server` or PHP's built-in server on a specified port, then automatically open the default web browser to that address.

View Snippet →
BASH

Monitor and Auto-Restart a System Service

Ensure your critical web services stay online with this bash script that periodically checks a service's status and automatically restarts it if it's found to be inactive.

View Snippet →
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 →