Premium
BASH Snippets.

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

BASH

Automating Timestamped Directory Backups

Learn how to create an automated bash script to back up a specified directory with a unique timestamp, ideal for web project deployments or configuration management.

View Snippet →
BASH

Checking if a Network Port is Open and Listening

Discover a concise bash snippet to verify if a specific TCP port is active and listening on your server, useful for debugging network services or pre-deployment checks.

View Snippet →
BASH

Recursively Find and Replace Text in Files

Implement a powerful bash command to recursively search and replace text strings across multiple files within a directory, perfect for batch code updates or configuration changes.

View Snippet →
BASH

Extracting Specific Data from Log Files

Master how to parse and extract specific information like IP addresses, request paths, or status codes from log files using powerful bash commands for quick analysis.

View Snippet →
BASH

Managing Environment Variables for Deployments

Learn to set and manage application-specific environment variables using a bash script, ensuring consistent configurations across different deployment environments.

View Snippet →
BASH

Backup a Directory with Timestamp and Retention

Create timestamped backups of a specified directory, compressing them and automatically deleting old backups to manage disk space efficiently.

View Snippet →
BASH

Monitor a Log File for Keywords and Trigger Action

Continuously monitor a specific log file for the occurrence of predefined keywords and execute an arbitrary command or script when detected.

View Snippet →
BASH

Automate Git Repository Update and Push

Streamline your development workflow with a script to pull latest changes, add new files, commit with a message, and push to a Git remote.

View Snippet →
BASH

Find and Replace String in Multiple Files Recursively

Recursively search and replace a specific string or pattern within the content of multiple files in a directory, perfect for refactoring or bulk updates.

View Snippet →
BASH

Manage Multiple Docker Containers with a Single Command

Create a unified script to start, stop, or restart multiple Docker containers by name or using a common naming convention, simplifying Docker management.

View Snippet →
BASH

Enforce HTTPS with HSTS in Nginx

Configure Nginx to implement HTTP Strict Transport Security (HSTS) to force clients to use HTTPS, protecting against downgrade attacks and cookie hijacking.

View Snippet →
BASH

Automate Log Rotation and Compression

Learn how to automate log file rotation and compression in Bash, saving disk space and managing server logs efficiently for web applications.

View Snippet →