Premium
BASH Snippets.

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

BASH

Load Environment Variables from .env Files

Discover how to securely load environment-specific variables from .env files into your bash scripts, preventing sensitive data from hardcoding.

View Snippet →
BASH

Automate Git Clone and Initial Setup

Streamline your development workflow by automating the cloning of a Git repository and performing initial setup tasks like dependency installation.

View Snippet →
BASH

Check for Required Commands and Install If Missing

Ensure your bash scripts have all necessary tools by checking for required commands and guiding users to install missing packages.

View Snippet →
BASH

Parse and Query JSON Data with jq

Efficiently parse, filter, and transform JSON data from API responses or files directly within your bash scripts using the powerful jq tool.

View Snippet →
BASH

Monitor Disk Space Usage and Alert

Monitor server disk space, identifying partitions nearing capacity and sending an alert if usage exceeds a predefined threshold, crucial for web server health.

View Snippet →
BASH

Graceful Reload of Web Server (Nginx/Apache)

Gracefully reload Nginx or Apache configuration without dropping active connections, essential for applying changes to web servers in production environments.

View Snippet →
BASH

Daily Web Server Log Archiving

Automate daily archiving and compression of web server access and error logs, reducing disk space usage and organizing logs for easier historical analysis.

View Snippet →
BASH

Check and Restart Web Service

Automate checking if a critical web service (e.g., Nginx, PHP-FPM) is running and restart it if inactive, ensuring continuous availability for your web applications.

View Snippet →
BASH

Simple Website Backup to Local/Remote

Create compressed backups of website files, storing them locally or transferring to a remote location, providing a safety net for web development projects.

View Snippet →
BASH

Load .env File into Bash Environment

Learn how to securely load environment variables from a .env file into your Bash session or scripts, enabling easy configuration management for web projects.

View Snippet →
BASH

Perform Authenticated API Request with curl

Discover how to use `curl` in Bash to make authenticated POST requests to web APIs, including sending JSON payloads and authentication headers.

View Snippet →
BASH

Update Configuration Value in File using sed

Learn how to use `sed` in Bash to programmatically update specific configuration values within text files, useful for automated server setups.

View Snippet →