Premium
BASH Snippets.

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

BASH

Batch Rename Files Using Regular Expressions

Learn how to efficiently rename multiple files in a directory using Bash and regular expressions, ideal for organizing project assets or logs.

View Snippet →
BASH

Implement Simple Cache Busting for Static Assets

Prevent browser caching issues for updated static files by automatically appending a unique timestamp or hash to their filenames in your build process.

View Snippet →
BASH

Recursively Clean Up Project Dependencies Directories

Free up disk space by recursively finding and deleting `node_modules`, `vendor`, or other specified dependency directories across multiple projects.

View Snippet →
BASH

Automating Website Backup to Remote Server

Learn to create a robust Bash script for backing up website files and databases, then securely transfer them to a remote server using tar and rsync.

View Snippet →
BASH

Automated Static Website Deployment with SCP/RSYNC

Learn how to write a Bash script for quickly deploying static website files to a remote web server using secure copy (scp) or rsync for efficiency.

View Snippet →
BASH

Archive and Clean Up Old Log Files

Implement a Bash script to manage server log files by archiving old logs, compressing them, and deleting original files to save disk space.

View Snippet →
BASH

Start Multiple Background Services for Development

Create a convenient Bash script to concurrently start and manage multiple development services, like a local server and a watcher, in the background.

View Snippet →
BASH

Create Timestamped Tar.gz Backup of a Directory

Learn how to create compressed, timestamped tar.gz archives of any directory, perfect for web application backups and versioning.

View Snippet →
BASH

Wait for a Specific Port to Become Available

Ensure dependent services start in the correct order by pausing script execution until a specified network port is listening, preventing connection errors.

View Snippet →
BASH

Load and Export .env Variables in Bash

A bash script to parse a `.env` file and export its key-value pairs as environment variables, commonly used for web application configuration.

View Snippet →
BASH

Nginx Service Control and Status Check Script

A bash script to check the status, start, stop, or restart the Nginx web server, useful for web server management and deployment workflows.

View Snippet →
BASH

Automate Git Clone and Dependency Install

A bash script to automate cloning a Git repository and installing common project dependencies (npm, Composer), ideal for new project setups.

View Snippet →