/ Linux Reviews / Beginners: Learn Linux / Advanced Bash-Scripting Guide - en Chapter 31. OptionsOptions are settings that change shell and/or script behavior. The set command enables options within a script. At the point in the script where you want the options to take effect, use set -o option-name or, in short form, set -option-abbrev. These two forms are equivalent. #!/bin/bash
set -o verbose
# Echoes all commands before executing.
#!/bin/bash
set -v
# Exact same effect as above.
#!/bin/bash
set -o verbose
# Command echoing on.
command
...
command
set +o verbose
# Command echoing off.
command
# Not echoed.
set -v
# Command echoing on.
command
...
command
set +v
# Command echoing off.
command
exit 0
An alternate method of enabling options in a script is to specify them immediately following the #! script header. #!/bin/bash -x
#
# Body of script follows.
It is also possible to enable script options from the command line. Some options that will not work with set are available this way. Among these are -i, force script to run interactive. bash -v script-name bash -o verbose script-name The following is a listing of some useful options. They may be specified in either abbreviated form (preceded by a single dash) or by complete name (preceded by a double dash or by -o). Table 31-1. Bash options
/ Linux Reviews / Beginners: Learn Linux / Advanced Bash-Scripting Guide |
Meet new people Adult Dating |