Bash & Shell Scripting (50 Qs)•Part 3: Advanced Text Processing & Production Internals (Senior / Lead)
How do you debug a Bash script (`set -x`, `bash -n`, `trap DEBUG`)?
senior Levelbash-shellAdvanced Text Processing
In Simple Words:
- Syntax Check without Execution:
bash -n script.sh(validates syntax errors). - Execution Tracing:
bash -x script.sh(prints every command and its expanded arguments prefixed with+). - ShellCheck: Run
shellcheck script.sh(static linter that detects hundreds of security risks, syntax bugs, and quoting errors).