Hi, of your using bash then the following two commands placed at the top of the script will help
Then when you run the script it will;
-
set -v Display the shell input lines as they are read
-
set -x Display the commands and their arguments as they are executed
As for logging, I've just recently inherited a load of shell scripts (at work) which I did not like much. So I've added logging and have been trying to add
testing code using the
bats (bash automated testing system). The testing code is quite tricky and is work in progress ;-)
However since I've opted to write my own simple logging function, I've taken out the product specific parts and it can be seen below. Works on Red Hat Linux, I tried on my Mac and seen a lot of date function errors.
Here's the code;
loggingUtility.sh
And here is an example of how to use;
I may put this into a git hub repository, time permitting.