Premium
BASH Snippets.

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

BASH

Automate MySQL Database Backups

Create a robust Bash script to automatically perform daily MySQL database backups, compressing them and optionally removing old backups to save disk space and ensure data safety.

View Snippet →
BASH

Initialize Git Repository and Add Remote

Quickly set up a new Git repository in your project directory, add an initial commit, and link it to a remote origin on GitHub, GitLab, or another service.

View Snippet →
BASH

Verify Essential System Commands

Create a robust shell script to check if crucial system commands like `node`, `npm`, `git`, or `docker` are installed before running critical development tasks.

View Snippet →
BASH

Automate Frontend Build Workflow

Streamline your web development workflow by automating the creation of output directories and execution of frontend build commands (e.g., Webpack, Vite, Gulp).

View Snippet →
BASH

Basic Web Service Endpoint Health Check

Perform a quick health check on a web service or API endpoint using `curl` in a bash script, verifying its HTTP status code for responsiveness.

View Snippet →
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 →