So far, we've talked about three different kinds of quoting:
), single quotes (
), and double quotes
The shells support yet one more kind of quoting, called
. A here document is useful when you need to
read something from standard input, but you don't
want to create a file to provide that input; you want to put that
input right into your shell script (or type it directly on the command line).
To do so, use the
operator, followed by a special word:
sort >file <<EndOfSort
This is very useful because
during this operation.
Here is a way to transfer a file using anonymous
from a shell script:
# ftpfile machine file
# set -x
ftp -n $SOURCE <<EndFTP
user anonymous $USER@`$GETHOST`
get $FILE /tmp/$BFILE
As you can see, variables and
command substitutions (9.16
If you don't want those to be done,
put a backslash in front of the name of the word:
cat >file <<\FunkyStriNG
Notice the funky string. This is done because
it is very unlikely that I will want to put that particular
characters in any file.
You should be warned that the C shell expects the
matching word (at the end of the list) to be escaped the same way, i.e.,
while the Bourne shell does not.
[Most Bourne shells also have the
The dash (
) at the end tells the shell to strip any TAB
characters from the beginning of each line.
Use this in shell scripts to indent a section of text without
passing those TABs to the command's standard input. -JP