Bash Recipes
View CommandsShell scripting commands for automation, text processing, conditionals, loops, and writing maintainable Bash scripts.
8 recipes
Parse CLI Arguments with getopts and Long Options
Handle short and long command-line options, required arguments, and positional parameters in bash scripts using getopts and case statements.
Automated Backup Script with Rotation
Create a bash script that performs timestamped backups of files and directories with configurable retention and automatic rotation of old backups.
Proper Error Handling with trap and set -euo pipefail
Implement robust error handling in bash scripts using set flags, trap for cleanup, error reporting with line numbers, and safe variable expansion.
Service Health Check Script with Notifications
Build a bash script that monitors service endpoints, checks response codes and latency, and sends alerts when services are down.
Process and Analyze Log Files with awk/sed/grep
Build a log processing pipeline to extract, filter, aggregate, and summarize information from application and server logs.
Run Commands in Parallel with xargs and GNU Parallel
Speed up batch operations by executing commands in parallel using xargs -P, GNU parallel, and background jobs with wait.
Production-Ready Bash Script Template
Create a reusable bash script template with strict error handling, argument parsing, logging, cleanup traps, and help text.
Text Processing Pipeline with sed, awk, cut, and sort
Build text processing pipelines to transform, extract, and aggregate data from CSVs, TSVs, and structured text files using standard Unix tools.