This example displays the output of the w, free, and df commands. You can
extend long shell command lines inside shell scripts or at the command line
by using the backslash character (), as follows:
Click here to view code image
matthew@seymour:~$ echo "this is a long \
command line and" ; echo "shows that multiple commands \
may be strung out."
this is a long command line and
shows that multiple commands may be strung out.
The first three lines of this example are a single command line. In that single
line are two instances of the echo command. Note that when you use the
backslash as a line-continuation character, it must be the last character on the
command line (or in your shell script, as you see later in this chapter, in the
“Writing and Executing a Shell Script” section).
Using the basic features of the shell command line is easy, but mastering use
of all features can be difficult. Entire books have been devoted to using shells,
writing shell scripts, and using pattern-matching expressions. The following
sections provide an overview of some features of the shell command line
related to writing scripts.
UNDERSTANDING GREP
If you plan to develop shell scripts to expand the capabilities of pattern-
matching commands such as grep, you will benefit from learning more
about using expressions. One of the definitive guides to using the pattern-
matching capabilities of UNIX and Linux commands is Mastering Regular
Expressions by Jeffrey E. F. Friedl.
Shell Pattern-Matching Support
The shell command line enables you to use strings of specially constructed
character patterns for wildcard matches. This is a different, simpler capability
than that supported by GNU utilities such as grep, which can use more
complex patterns, known as expressions, to search through files or directories
or to filter data input to or out of commands.
The shell’s pattern strings can be simple or complex, but even using a small
subset of the available characters in simple wildcards can yield constructive
results at the command line. Common characters used for shell pattern
matching include the following:
*—Matches any character. For example, to find all files in the current