Bash Script Flags

by Vivek Gite on August 14, 2006 · 0 comments

Can you explain me common UNIX / Linux / Mac OS X / BSD bash shell script flags?

You can pass -v and -x option to #!/bin/sh or #!/bin/bash:

Flags

  1. The -v option displays each command before executing it. This is the equivalent of inserting set -v in the script.
  2. The -x option displays the result each command. This is the equivalent of inserting set -x in the script.

Above flags are useful for debugging shell problems:

#!/bin/sh -x
FILE="/etc/resolv.conf"
echo "This is a test"
[ ! -f $FILE ] || echo "File $FILE does not exist"

You can run them from command prompt itself:

sh -x /path/to/script
bash -xv /path/to/script
sh -nv /path/to/script

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 6 + 7 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: