The -v option tells the shell to run in verbose mode. In practice, this means that the shell will echo each command prior to executing the command. This will be useful in locating the line of script that has created an error.
We can enable the script execution with the -v option as follows:
$ bash -v hello.sh
Another way is by modifying the shebang line as follows:
In this case, we can run the script with the -v option as follows:
$ chmod u+x hello.sh $ ./hello.sh
Let's write the debug_02.sh script as follows:
#!/bin/bash echo "Hello $LOGNAME" echo "Today is `date` echo "Your present working directory is $PWD echo Good-bye $LOGNAME
Save the file, give the permission to execute, ...