Skip to Content
Learning Linux Shell Scripting - Second Edition
book

Learning Linux Shell Scripting - Second Edition

by Ganesh Sanjiv Naik
May 2018
Beginner
332 pages
7h 28m
English
Packt Publishing
Content preview from Learning Linux Shell Scripting - Second Edition

Debugging mode - displaying commands (option -v)

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:

#!/bin/bash  -v

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, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Linux Shell Scripting

Learning Linux Shell Scripting

Ganesh Sanjiv Naik
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar

Publisher Resources

ISBN: 9781788993197Supplemental Content