Debug Linux shell scripts with ‘-x’
alvin
December 17, 2011 - 12:30pm
- Read more about Debug Linux shell scripts with ‘-x’
- Log in to post comments
If you ever need to debug a Unix or Linux shell script, you can just add the -x option to the interpreter when you invoke it. You can add the shell's debug option on the command line like this:
sh -x misbehaving_script.sh
or at the end of the first line in your shell script (the she-bang line), like this:
#!/bin/sh -x
I was just working on a shell script related to fonts on a Mac OS X (Unix), system, and when I tried to run it normally, all it gave me was this error message: