Premium
BASH Snippets.

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

BASH

Verify and Install Essential Command-Line Tools

Automate the verification and installation of critical command-line tools required for your development environment, ensuring all dependencies are met for your projects and setups.

View Snippet →
BASH

Batch Git Pull Across Multiple Repositories

Streamline your workflow by automating the process of pulling the latest changes from multiple Git repositories within a specified root directory, ideal for monorepos or related projects.

View Snippet →
BASH

Make HTTP Requests with Error Handling using Curl

Learn to perform robust HTTP GET requests using `curl` in Bash, including checking HTTP status codes for success or failure and handling network issues, useful for API health checks and simple integrations.

View Snippet →
BASH

Automate System Package Updates

A robust Bash script to efficiently update and upgrade system packages on Debian/Ubuntu and RHEL/CentOS distributions, ensuring your servers are up-to-date and secure.

View Snippet →
BASH

Check and Restart a Linux Service

A robust Bash script to check if a specific systemd service is running and restart it if it's inactive or failed, ensuring service continuity for web applications.

View Snippet →
BASH

Parse JSON with JQ in Bash

Learn to parse and extract specific data from JSON output using the powerful `jq` command-line JSON processor in your Bash scripts for API integration and data processing.

View Snippet →
BASH

Synchronize Directories with Rsync

A flexible Bash script for efficient one-way synchronization of files and directories using `rsync`, perfect for deployment of static assets, local backups, or asset management.

View Snippet →
BASH

Generate Random Alphanumeric String

A simple Bash script to generate a cryptographically strong, random alphanumeric string of a specified length, useful for temporary passwords, API keys, or unique identifiers.

View Snippet →
BASH

Automate Cleanup of Project Directories

Efficiently clean up common project artifacts like `node_modules`, `dist`, `build`, and `vendor` directories across multiple subdirectories to free up disk space.

View Snippet →
BASH

Clean Up Stale Git Branches

Automate the deletion of local Git branches that have already been merged into your main development branch, helping to keep your repository clean and manageable.

View Snippet →
BASH

Real-time Log Monitoring for Errors

Continuously monitor a specified log file for the occurrence of error messages or custom keywords, providing real-time alerts for debugging and system health checks.

View Snippet →
BASH

Backup Critical Configuration Files

Create timestamped tar.gz backups of important configuration files or directories, ensuring you have a restore point before making system-level changes.

View Snippet →