You need to debug a shell script.
Most shells (zsh, ksh, bash …) can either run with a minus x (-x) option or by specifying set -x.
If you have an existing shell, that you’d like to run in debug mode – just run it like this: bash -x scriptname. Or ksh -x for korn shell.
You can also edit the follow and put a minus x after the interpreter line, for example:
Debugging on the command line can be performed, simply by typing set -x. Like this:
$ set -x
+ set -x
Tue Jun 13 18:59:44 WST 2006
$ echo "hello world"
+ echo 'hello world'
$ set +x
+ set +x
Tue Jun 13 18:59:57 WST 2006
[tags]Debug Shell Scripts, Unix Coding School[/tags]
[/reference]If you have found my website useful, please consider buying me a coffee below 😉