Premium
BASH Snippets.

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

BASH

Automate Git Pull, Dependency Install, and Service Restart for Web Deployments

A Bash script to automate web application deployments. It pulls the latest code, installs dependencies, and restarts your service efficiently.

View Snippet →
BASH

Parse and Query JSON Data from the Command Line with jq

Master 'jq' for command-line JSON processing. Extract values, filter arrays, and format API responses or config files directly in your terminal.

View Snippet →
BASH

Securely Execute Commands on Remote Servers via SSH

Learn to securely run commands on remote servers using SSH. Execute single commands, multi-line scripts, and pass arguments for server management.

View Snippet →
BASH

Implement a Basic Web Service Health Check Script

Create a simple Bash script to check the availability and HTTP status code of a web service or API endpoint using `curl`, crucial for monitoring.

View Snippet →
BASH

Run Bash Commands in the Background Reliably with nohup

Use `nohup` and `&` to run long-running commands or services in the background, ensuring they continue even after logging out.

View Snippet →
BASH

Find and Replace String in Multiple Files

Safely find and replace a specific string across multiple files within a directory, with an optional backup, using `find` and `sed` commands for web project refactoring.

View Snippet →
BASH

Graceful Web Service Restart with Config Check

Safely restart or reload common web services like Nginx, Apache, or PHP-FPM after configuration changes, including a syntax check before reloading to prevent downtime.

View Snippet →
BASH

Automated Cleanup of Old Files by Age

Automate the cleanup of old log files, cache files, or temporary directories by deleting files older than a specified number of days, helping manage disk space on web servers.

View Snippet →
BASH

Check File or Directory Existence and Create if Missing

Ensure critical files or directories exist before script execution, creating them if necessary, to prevent errors in your web development workflows.

View Snippet →
BASH

Monitor Disk Space Usage with Threshold Alert

Script to monitor server disk space, alerting web developers when usage exceeds a defined percentage to prevent critical storage issues.

View Snippet →
BASH

Batch Rename Files with a Pattern or String Replacement

Automate renaming multiple files in a directory using a specified pattern or string replacement, perfect for organizing web assets.

View Snippet →
BASH

Download Files from URL with Progress and Checksum Verification

Securely download files from a URL using `curl` or `wget`, display progress, and verify integrity with a checksum for reliable asset retrieval.

View Snippet →