Bash Scripting
91
Command
Function
fg
Brings a job to the foreground
getopts
Parses arguments
to the shell script
jobs
Lists background (bg) jobs
pwd
Displays the current directory
read
Reads a line from standard input
readonly
Declares as variable as read-only
set
Lists
all variables
shift
Moves the script's input parameters to the left, dropping the first
parameter (useful for consuming all parameters one at a time)
test
Evaluates arguments
[[
Performs a conditional test
times
Prints the user and system times
trap
Traps a signal so the script can handle it (untrapped signals terminate
the script)
type
Displays how each argument would
be interpreted as a command
umask
Changes the default permissions for a new file
unset
Deletes values from a variable or function
wait
Waits for a background process to complete
Summary
Scripting is an essential skill for any hacker or system administrator. It
enables you to automate tasks that would normally
take hours of your time,
and once the script is saved, it can be used over and over again. Bash script-
ing is the most basic form of scripting, and
you will advance to Python
scripting with even more capabilities in Chapter 17.