I enjoy writing bash scripts as they will do a chunk of work for me within no time by just executing a single command.
But to make my script perform requested operation, many a times i need to debug it and make it work proper.
1) To debug a script use below command
$bash -x ./my_script.sh
2) To debug only part of a script use set -x and set +x at start and end of code snippet.
Ex:
$vim my_script.sh
#!/bin/bash
...
...
set -x
...
...
set +x
....
#./my_script.sh
3) In script, one can always use "echo" before any particular command to watch its contents.
No comments:
Post a Comment