Premium
BASH Snippets.

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

BASH

Automate Updating Multiple Git Repositories

A Bash script to efficiently navigate through multiple Git repositories within a parent directory and pull the latest changes, streamlining your development workflow.

View Snippet →
BASH

Automatically Remove Old Files and Directories

Use a Bash script to automatically find and delete files or empty directories older than a specified duration, ideal for routine cleanup of logs, cache, or temporary data.

View Snippet →
BASH

Extract Key-Value Pairs from Configuration Files

A powerful Bash snippet to parse and extract specific configuration values (e.g., database host, API keys) from text-based configuration files using grep and awk.

View Snippet →
BASH

Basic Command Line Argument Parsing in Bash

Implement simple command-line argument parsing in your Bash scripts to accept flags and values, making your scripts more flexible and user-friendly for various operations.

View Snippet →
BASH

Securely Sync Local Files to Remote Server with Rsync

Automate secure file deployments from your local machine to a remote web server using rsync, ensuring only changed files are transferred efficiently.

View Snippet →
BASH

Automate Compressed MySQL Database Backups

Learn to create automated, timestamped, and gzipped backups of your MySQL or MariaDB databases, essential for disaster recovery and data protection.

View Snippet →
BASH

Check and Restart Web Service if Down

Create a robust Bash script to periodically check the status of a web service (e.g., Nginx, Apache) and automatically restart it if it's not running.

View Snippet →
BASH

Automate Project Dependency Installation

Streamline project setup by automatically detecting and installing Node.js, Python, or Ruby dependencies based on common lock files, saving development time.

View Snippet →
BASH

Find and Kill Process Running on a Specific Port

Quickly identify and terminate any process occupying a specified TCP port, essential for resolving port conflicts during web development server startups.

View Snippet →
BASH

Monitor File Changes and Trigger a Command

Create a simple file watcher using `inotifywait` that automatically executes a specified command, like a build script or server restart, when files in a directory change.

View Snippet →
BASH

Batch Rename Multiple Files Using Regular Expressions

Efficiently rename a collection of files in a directory by applying a regular expression search and replace pattern, ideal for organizing assets or refactoring filenames.

View Snippet →
BASH

Add or Remove Local Host Entries for Development

Easily manage entries in your `/etc/hosts` file, allowing you to map custom domain names (e.g., `myapp.local`) to `127.0.0.1` for local web development.

View Snippet →