Premium
BASH Snippets.

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

BASH

Check and Restart Web Service

Automate checking if a critical web service (e.g., Nginx, PHP-FPM) is running and restart it if inactive, ensuring continuous availability for your web applications.

View Snippet →
BASH

Simple Website Backup to Local/Remote

Create compressed backups of website files, storing them locally or transferring to a remote location, providing a safety net for web development projects.

View Snippet →
BASH

Load .env File into Bash Environment

Learn how to securely load environment variables from a .env file into your Bash session or scripts, enabling easy configuration management for web projects.

View Snippet →
BASH

Perform Authenticated API Request with curl

Discover how to use `curl` in Bash to make authenticated POST requests to web APIs, including sending JSON payloads and authentication headers.

View Snippet →
BASH

Update Configuration Value in File using sed

Learn how to use `sed` in Bash to programmatically update specific configuration values within text files, useful for automated server setups.

View Snippet →
BASH

Set Secure Web Project File Permissions

Secure your web applications by correctly setting file and directory permissions in Bash, ensuring proper access for the web server while maintaining security.

View Snippet →
BASH

Create Basic Web Project Directory Structure

Quickly bootstrap new web projects by generating a standard directory and file boilerplate structure using a simple Bash script.

View Snippet →
BASH

Automate Git Pull and Application Restart for Deployments

Streamline web application deployments by automatically pulling the latest code from a Git repository and restarting a systemd service, ensuring quick updates.

View Snippet →
BASH

Check Website Availability with HTTP Status Codes

A simple bash script to verify the availability and health of a website by checking its HTTP status code, useful for monitoring and automated health checks.

View Snippet →
BASH

Parse Command Line Arguments in Bash Scripts

Learn to create flexible and user-friendly bash scripts by implementing robust command-line argument parsing for flags and options with values.

View Snippet →
BASH

Monitor Log Files for Patterns and Trigger Actions

Create a robust log monitoring script that continuously watches a log file for specific error patterns and executes custom actions, enhancing system observability.

View Snippet →
BASH

Manage Node.js Versions with NVM

Learn how to efficiently switch between different Node.js versions using nvm (Node Version Manager) in your development environment for various project requirements.

View Snippet →