Skip to main content
InterviewHubPRO
Section Overview
Q32

Question 32 of 50

Part 3: Advanced Text Processing & Production Internals (Senior / Lead)

64%
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:

  1. Syntax Check without Execution: bash -n script.sh (validates syntax errors).
  2. Execution Tracing: bash -x script.sh (prints every command and its expanded arguments prefixed with +).
  3. ShellCheck: Run shellcheck script.sh (static linter that detects hundreds of security risks, syntax bugs, and quoting errors).