Skip to content
Justice Tech School

Debugging Scripts

Run with bash -x to trace each command, add set -x around a section, and use shellcheck to find mistakes before running. echo and PS4 help trace.

Example
set -x
a=1
b=$((a + 1))
set +x
echo "done $b"

Result

done 2

Exercise

Trace commands.

bash  script.sh

Quiz Test

What does set -x do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.