Debugging the entire script:
bash -x myScript.sh
Debugging parts of script:
set -x : activate debugging.Example:
set +x : stop debugging.
#!/bin/bashAlternative:
echo "Simple example script\n"
set -x
for i in $(seq 3)
do
echo "Hello World!"
done
set +x
echo "Done debugging!"
exit 0
Replace the shebang with following:
#!/bin/bash -xv
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
No comments:
Post a Comment