Premium
BASH Snippets.

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

BASH

Automate Project Dependency Installation

Streamline project setup by automatically detecting and installing Node.js, Python, or Ruby dependencies based on common lock files, saving development time.

View Snippet →
BASH

Find and Kill Process Running on a Specific Port

Quickly identify and terminate any process occupying a specified TCP port, essential for resolving port conflicts during web development server startups.

View Snippet →
BASH

Monitor File Changes and Trigger a Command

Create a simple file watcher using `inotifywait` that automatically executes a specified command, like a build script or server restart, when files in a directory change.

View Snippet →
BASH

Batch Rename Multiple Files Using Regular Expressions

Efficiently rename a collection of files in a directory by applying a regular expression search and replace pattern, ideal for organizing assets or refactoring filenames.

View Snippet →
BASH

Add or Remove Local Host Entries for Development

Easily manage entries in your `/etc/hosts` file, allowing you to map custom domain names (e.g., `myapp.local`) to `127.0.0.1` for local web development.

View Snippet →
BASH

Analyze Web Server Logs for Errors

Automate analysis of web server logs to quickly identify and count common error types like 404s and 500s, streamlining debugging and monitoring.

View Snippet →
BASH

Create Timestamped Compressed Backups

Automate creation of timestamped, compressed backups of directories or project files, ensuring data integrity and easy recovery for web projects.

View Snippet →
BASH

Check Git Status and Pull Latest Changes

Automate checking the Git status of a repository for uncommitted changes or untracked files, and pull the latest changes from a specified branch, ensuring your repo is up-to-date.

View Snippet →
BASH

Make HTTP Request and Extract JSON Field with jq

Effortlessly make HTTP GET requests to API endpoints using `curl` and parse JSON responses with `jq` to extract specific data fields, useful for scripting API interactions.

View Snippet →
BASH

Delete Old Files or Directories by Age

Automate the efficient cleanup of old files or empty directories within a specified path based on their age using `find`, perfect for managing logs, caches, and temporary data.

View Snippet →
BASH

Interactive Script with User Menu and Actions

Create an interactive Bash script with a dynamic menu, allowing users to select and execute various administrative or development tasks through a `case` statement, streamlining workflows.

View Snippet →
BASH

Checking Web Service Health Status

A bash script to perform a quick HTTP health check on a given URL, returning its status code to verify service availability and responsiveness.

View Snippet →