Both the Bourne shell and the C shell support multiline commands.
In the Bourne shell, a newline following an open quote (
a pipe symbol (
|), or a backslash (
\) will not cause the command
to be executed.
Instead, you'll get a secondary prompt (from the
PS2 environment variable, set to
> by default) and you can
continue the command on the next line.
For example, to send a quick
message without making the
other user wait for you to type the message:
echo "We're leaving in 10 minutes. See you downstairs." |>
In the C shell, you can continue a line by. You won't get the secondary prompt.
Obviously, this is a convenience if you're typing a long command line. It is a minor feature and one easily overlooked; however, it makes it much easier to use a program likefrom the command line. For example, if you know you chronically make the typos "mvoe" (for "move") and "thier" (for "their"), you might be inspired to type the following command:
More importantly, the ability to issue multiline
commands lets you use the shell's programming
features interactively from the command line.
In both the Bourne and the C shell, multiline programming constructs
automatically generate a secondary prompt (
> in the Bourne
? in the C shell) until the construct is completed.
For example, here's a place to use my favorite programming construct for non-programmers, the:
for x in file1 file2 file3>
sed 's/thier/their/g' $x > ,$x>
mv ,$x $x>
Or in the C shell with:
foreach x (file1 file2 file3)?
sed 's/thier/their/g' $x > ,$x?
mv ,$x $x?
While a simple command like this could be saved into a, it is often even easier to use it interactively.
Users of sed should of course