Saturday, 9 June 2012

how to debug linux bash script

bash - GNU Bourne-Again SHell. Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file.  Bash also incorporates useful features from the Korn and C shells (ksh and csh).

-x parameter puts bash into debug mode, so if you would like to execute your bash script in debug mode, you can do it this way:

# bash -x

another solution is to add "set -x" line into your script, but you have to remember that this will make your script produce debug output every time it's executed. If you prefer this way, just add "set -x" line at the begining of script:

set -x

No comments:

Post a Comment