Premium
BASH Snippets.

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

BASH

Automate Static Website Deployment via SCP

Streamline static website deployment to a remote server using a simple bash script that utilizes SCP for efficient and secure file transfer.

View Snippet →
BASH

Basic Log File Rotation and Archiving

Implement a straightforward bash script to rotate and archive application log files, preventing excessive disk usage and maintaining a clean server environment.

View Snippet →
BASH

Processing JSON Data in Bash with JQ

Master parsing and manipulating JSON data in Bash scripts using the powerful `jq` command-line JSON processor, essential for API interactions and data extraction.

View Snippet →
BASH

File Integrity Check with MD5/SHA256

Ensure file integrity in Bash scripts using MD5 or SHA256 checksums to verify downloads or detect unauthorized modifications, crucial for secure deployments.

View Snippet →
BASH

Loading Environment Variables from a .env File

Securely manage configuration in Bash scripts by loading environment variables from a `.env` file, preventing hardcoding sensitive data and improving portability.

View Snippet →
BASH

Robust File Download with Progress and Retries

Implement robust file downloads in Bash scripts using `curl` with progress indicators, timeout handling, and automatic retries for reliable fetching of external resources.

View Snippet →
BASH

Automating Daily Directory Backups with Timestamping

Learn to create a robust Bash script for daily directory backups, including timestamping archives and automatically cleaning up old backups to save disk space.

View Snippet →
BASH

Checking if a TCP Port is Listening for Service Availability

Utilize this Bash snippet to quickly verify if a specific TCP port is actively listening on a host, crucial for checking web server or database service availability and diagnostics.

View Snippet →
BASH

Automating Website Deployment with Git Pull and Service Restart

Streamline your web deployments with this Bash script that pulls the latest code from Git, updates dependencies, and restarts essential services like Nginx or PHP-FPM.

View Snippet →
BASH

Analyzing Web Server Logs for Top Requesting IP Addresses

Quickly identify the top IP addresses accessing your web server by parsing Nginx or Apache access logs using `awk`, `sort`, and `uniq` commands for traffic analysis and security.

View Snippet →
BASH

Conditional Script Execution Based on File or Directory Existence

Enhance script robustness by using Bash conditionals to check for file or directory existence before executing commands, preventing errors and adapting to various project structures.

View Snippet →
BASH

Advanced Log Filtering and Error Extraction

Use this Bash snippet to efficiently filter log files, extract specific error patterns, and count their occurrences for quick debugging and system health checks.

View Snippet →