Tuesday, December 28, 2010

How to debug a bash script in Linux

To debug a bash script, you need to run a shell script with -x option from the command line itself:
bash -x scriptname
or
bash -xv scriptname

You can also modify shebang line to run an entire script in debugging mode.

#!/bin/bash -x
echo "Hello ${USER}"
echo "Today is $(date)"

No comments:

Post a Comment

There was an error in this gadget