Premium
BASH Snippets.

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

BASH

Timestamped Directory Backup with Rsync

A robust bash script for creating efficient, timestamped backups of important directories using rsync, ensuring data integrity and versioning.

View Snippet →
BASH

Extracting and Exporting Environment Variables from .env

A bash script to parse a .env file, ignoring comments and empty lines, and export key-value pairs as environment variables for use in shell sessions or scripts.

View Snippet →
BASH

Configure Essential Security Headers in Nginx

Enhance web application security by configuring critical HTTP security headers like X-Content-Type-Options and Referrer-Policy directly within your Nginx server block.

View Snippet →
BASH

Automate Git Pull & Status for Multiple Repos

Streamline your workflow by automating `git pull` and checking the status across multiple Git repositories in different directories with a single Bash script.

View Snippet →
BASH

Sync Files for Deployment with `rsync`

Efficiently synchronize local development files to a remote server for deployment or backup, excluding sensitive files, using `rsync` in a Bash script.

View Snippet →
BASH

Extract Log Data with `grep` and `awk`

Efficiently filter and extract specific data from large log files (e.g., web server access logs) using a combination of `grep` for pattern matching and `awk` for column-based extraction.

View Snippet →
BASH

Manage Config Files with Conditional Creation

Create and manage application configuration files or environment variable files in Bash, ensuring they exist and are populated with default content if missing.

View Snippet →
BASH

Monitor Website Availability with Bash

A Bash script to periodically check if a website is online and notify if it's down, useful for site reliability and basic health checks.

View Snippet →
BASH

Create Timestamped Backups of Directories

A Bash script to automatically create compressed, timestamped backups of a specified directory, essential for data recovery and versioning.

View Snippet →
BASH

Parse and Extract Data from JSON with `jq`

Learn how to use `jq` in Bash to efficiently parse JSON output from APIs or files, extracting specific fields and transforming data for scripting.

View Snippet →
BASH

Check and Restart a Linux Service or Process

A Bash script to verify if a specified process or service is running and, if not, restart it, ensuring continuous application availability.

View Snippet →
BASH

Check SSL Certificate Expiry and Send Notification

Monitor the expiration date of an SSL certificate for a given domain and send a notification if it's nearing expiry, preventing service interruptions.

View Snippet →