start page | rating of books | rating of authors | reviews | copyrights

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 8.16 Quoting Handles Special Characters in Filenames Chapter 8
How the Shell Interprets What You Type
Next: 8.18 Here Documents
 

8.17 verbose and echo Variables Show Quoting

The C shell has two variables (6.9) that, when set, will help you follow the convoluted trail of variable and metacharacter expansion. This will echo every command line before shell variables have been evaluated:

set 
% set verbose

This command will display each line after the variables and metacharacters have been substituted:

% set echo

If you wish to turn the variables off, use unset (6.8) instead of set.

The Bourne shell syntax is different. To turn on the verbose flag, use:

$ set -v

The command set -x turns on the echo flag. You can also type them together: set -xv.

If your version of UNIX understands (44.4) scripts that start with #!, here's a convenient way to turn these variables on from the first line of a script:

#!/bin/sh -xv

It is not necessary to modify the program. You can enable variable tracing in Bourne shell scripts by typing the shell name and options on the command line:

$ sh -v script
$ sh -x script

Not all Bourne shells let you turn these variables off. If yours does, you can do it by using a plus sign instead of a minus sign:

set +xv

- BB


Previous: 8.16 Quoting Handles Special Characters in Filenames UNIX Power ToolsNext: 8.18 Here Documents
8.16 Quoting Handles Special Characters in Filenames Book Index8.18 Here Documents

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System