Premium
BASH Snippets.

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

BASH

Parse JSON Data from CLI with JQ

Learn to parse and query JSON data directly from the command line using the powerful `jq` utility in your bash scripts, perfect for API interactions or config files.

View Snippet →
BASH

Automate Node.js Dependency Installation

Create a bash script to intelligently check for Node.js project dependencies (`node_modules`) and automatically install them if missing using npm or yarn.

View Snippet →
BASH

Batch Rename Files with Sequential Numbering

Effortlessly rename multiple files in a directory, adding sequential numbers and maintaining file extensions, ideal for managing image assets or documents.

View Snippet →
BASH

Check and Kill Process Using a Specific Port

Write a bash script to detect if a given network port is in use and, if so, identify and offer to kill the process occupying it, preventing development server conflicts.

View Snippet →
BASH

Start a Quick Local Static File Server

Launch an instant local web server using Python's http.server or PHP's built-in server from any directory, perfect for quickly testing static web pages.

View Snippet →
BASH

Automate Web Server Configuration Reload

A bash script to gracefully reload web server configurations (e.g., Nginx, Apache) after updates, ensuring changes apply without downtime for web applications.

View Snippet →
BASH

Automate Database Backups (MySQL/PostgreSQL)

A robust bash script for automating daily or scheduled backups of MySQL or PostgreSQL databases, crucial for disaster recovery in web development.

View Snippet →
BASH

Basic Web App Deployment Script

A foundational bash script for deploying web applications, covering code pull, dependency installation, build process, and service restart.

View Snippet →
BASH

Find and Replace Text Across Files

A powerful bash script utilizing `find` and `sed` to efficiently search for and replace text patterns across multiple files in a web project directory.

View Snippet →
BASH

Automate Log Archiving and Cleanup

Create a Bash script to automatically rotate, compress, and clean up old log files, managing disk space and maintaining server health efficiently.

View Snippet →
BASH

Monitor Website Uptime and HTTP Status

Deploy a Bash script to regularly check a website's availability and HTTP status code using `curl`, providing essential proactive monitoring for web services.

View Snippet →
BASH

Securely Sync Files to a Remote Server with rsync

Learn to use `rsync` in a Bash script for efficient, secure, and incremental file synchronization to a remote server, perfect for website deployments.

View Snippet →