bashAvoid common Bash mistakes — quoting traps, word splitting, and subshell gotchas.
Install via ClawdBot CLI:
clawdbot install ivangdavila/bashRequires:
| Topic | File |
|-------|------|
| Arrays and loops | arrays.md |
| Parameter expansion | expansion.md |
| Error handling patterns | errors.md |
| Testing and conditionals | testing.md |
"$var" not $var, spaces break unquoted"${arr[@]}" preserves elements—${arr[*]} joins into single string'$var' doesn't expand"$(command)" not $(command)$var splits on whitespace—file="my file.txt"; cat $file fails expands to files—quote or escape if literal: "" or \*set -f disables globbing—or quote everything properly[[ ]] preferred over [ ]—no word splitting, supports &&, ||, regex[[ $var == pattern* ]]—glob patterns without quotes on right side[[ $var =~ regex ]]—regex match, don't quote the regex-z is empty, -n is non-empty—[[ -z "$var" ]] tests if emptycat file | while read; do ((count++)); done—count lostwhile read < file or process substitution—while read; do ...; done < <(command)( ) is subshell, { } is same shell—variables in ( ) don't persistset -e exits on error—but not in if, ||, && conditionsset -u errors on undefined vars—catches typosset -o pipefail—pipeline fails if any command fails, not just lasttrap cleanup EXIT—runs on any exit, even errorsarr=(one two three)—or arr=() then arr+=(item)${#arr[@]}—not ${#arr}"${arr[@]}"—always quote${!arr[@]}—useful for sparse arrays${var:-default}—use default if unset/empty${var:=default}—also assigns to var${var:?error message}—exits with message${var:0:5}—first 5 chars${var#pattern}—## for greedy$(( )) for math—result=$((a + b))(( )) for conditions—if (( count > 5 )); then$ needed inside $(( ))—$((count + 1)) not $(($count + 1))[ $var = "value" ] fails if var empty—use [ "$var" = "value" ] or [[ ]]if [ -f $file ] with spaces—always quote: if [[ -f "$file" ]]local in functions—without it, variables are globalread without -r—backslashes interpreted as escapesecho portability—use printf for reliable formattingGenerated Mar 1, 2026
Automating server provisioning, deployment pipelines, and infrastructure management using Bash scripts. Proper error handling ensures deployment reliability, while parameter expansion and arrays help manage configuration variables and environment-specific settings across multiple servers.
Building data extraction, transformation, and loading workflows that process log files, CSV exports, or API responses. Using proper quoting prevents word splitting issues with filenames containing spaces, while exit handling ensures failed processing steps don't corrupt downstream data.
Creating monitoring scripts that check system health, disk usage, service status, and generate alerts. Test brackets with regex patterns help parse log files, while trap commands ensure cleanup runs even when scripts exit due to critical errors.
Scripting software build processes, dependency installation, and package creation for distribution. Arrays manage build targets and platforms, while subshell awareness prevents variable scope issues when chaining compilation steps through pipes.
Implementing automated backup routines that compress, encrypt, and transfer critical data to storage systems. Proper quoting handles filenames with special characters, while arithmetic operations calculate retention periods and storage usage metrics.
Offering Bash scripting as part of a managed service for automating customer infrastructure. Revenue comes from subscription fees for script maintenance, monitoring, and optimization services that ensure reliable automation with proper error handling and security practices.
Providing expert Bash scripting services to organizations migrating to automated workflows. Revenue streams include project-based consulting for script development, plus training workshops that teach teams to write reliable scripts with proper quoting and error patterns.
Maintaining a curated collection of production-ready Bash scripts for common IT tasks. Revenue comes from licensing fees for enterprise access to tested scripts with documentation, plus premium support for customization and integration assistance.
đź’¬ Integration Tip
Integrate Bash scripts into CI/CD pipelines by using proper exit codes and pipefail settings to ensure build failures propagate correctly. Always test scripts in isolated environments before production deployment.
Remote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output.
Command-line tool to manage Google Workspace services including Gmail, Calendar, Drive, Sheets, Docs, Slides, Contacts, Tasks, People, Groups, and Keep.
Runs shell commands inside a dedicated tmux session named claw, captures, and returns the output, with safety checks for destructive commands.
A modern text-based browser. Renders web pages in the terminal using headless Firefox.
Write robust, portable shell scripts. Use when parsing arguments, handling errors properly, writing POSIX-compatible scripts, managing temp files, running commands in parallel, managing background processes, or adding --help to scripts.
NotebookLM CLI wrapper via `node {baseDir}/scripts/notebooklm.mjs`. Use for auth, notebooks, chat, sources, notes, sharing, research, and artifact generation/download.