Premium
BASH Snippets.

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

BASH

Processing Log Files and Extracting Data

Learn to efficiently process log files in Bash, using `grep`, `awk`, and `sed` to filter, extract, and transform specific data, invaluable for monitoring and debugging web applications.

View Snippet →
BASH

Running Commands on Remote Server via SSH

Execute commands on a remote server securely using SSH in Bash scripts, covering passwordless authentication, command execution, and file transfer (scp), crucial for server management.

View Snippet →
BASH

Automating Website & Database Backups

Create a robust Bash script to automate daily backups of your website files and MySQL/PostgreSQL databases, ensuring data safety and easy recovery.

View Snippet →
BASH

Basic Git-based Website Deployment

Streamline your web project deployments with a Bash script that pulls the latest code from Git, installs dependencies, and sets file permissions.

View Snippet →
BASH

Monitor Disk Space and Send Email Alert

Proactively monitor server disk usage with a Bash script. It checks partitions and sends an email alert if usage exceeds a defined threshold, preventing downtime.

View Snippet →
BASH

Archive and Clean Old Log Files

Maintain server health and free up disk space by automatically archiving and removing old log files, ensuring efficient log management.

View Snippet →
BASH

Find and Replace Text in Multiple Files

Perform quick and powerful text replacements across numerous files in your project using a single Bash command, ideal for refactoring or bulk updates.

View Snippet →
BASH

Configure Essential Security HTTP Headers in Nginx

Enhance your web application's security by configuring critical HTTP headers like HSTS, X-Frame-Options, X-Content-Type-Options, and CSP directly in your Nginx server block.

View Snippet →
BASH

Automating Git Pull and Build on a Server

A bash script to automate pulling the latest code from a Git repository, installing dependencies, and building a web project on a remote server for deployments.

View Snippet →
BASH

Archive and Rotate Web Server Log Files

A bash script to archive web server log files with a timestamp, compress them, and optionally remove old archives to manage disk space on the server.

View Snippet →
BASH

Parse JSON Output with JQ

A bash script demonstrating how to parse and extract specific values from a JSON string or file using the powerful command-line JSON processor, 'jq'.

View Snippet →
BASH

Simple Timestamped File and Directory Backup

A bash script to create timestamped backups of individual files or entire directories, compressing them into `.tar.gz` archives for safe storage.

View Snippet →