Shell Script Debug
08 Sep 2018 Linux tips shellThis post contains a tip from TACC helping debug the shell script.
Tip 155:
A nice way to debug shell scripts is to define the bash shell function “shdebug” shown below.shdebug () { env PS4=' ${BASH_SOURCE}:${LINENO}(${FUNCNAME[0]}) ' sh -x $1; }
This will give the file, line number and function name for each line in a shell script. To use do:
shdebug /path/to/bash_shell_script
Credits
- TACC - Texas Advanced Computing Center