Special Characters


Special characters, which have a special meaning to the shell, are discussed in "Filename Generation/Pathname Expansion" on page 221. These characters are mentioned here so that you can avoid accidentally using them as regular characters until you understand how the shell interprets them. For example, it is best to avoid using any of the following characters in a filename (even though emacs and some other programs do) because they make the file harder to reference on the command line:

& ; | * ? ' " ' [ ] ( ) $ < > { } # / \ ! ~


Whitespace


Although not considered special characters, RETURN, SPACE, and TAB also have special meanings to the shell. RETURN usually ends a command line and initiates execution of a command. The SPACE and TAB characters separate elements on the command line and are collectively known as whitespace or blanks.

Quoting special characters


If you need to use a character that has a special meaning to the shell as a regular character, you can quote (or escape) it. When you quote a special character, you keep the shell from giving it special meaning. The shell treats a quoted special character as a regular character. However, a slash (/) is always a separator in a pathname, even when you quote it.

Backslash


To quote a character, precede it with a backslash (\). When two or more special characters appear together, you must precede each with a backslash (for example, you would enter ** as \*\*). You can quote a backslash just as you would quote any other special characterby preceding it with a backslash (\\).

Single quotation marks


Another way of quoting special characters is to enclose them between single quotation marks: '**'. You can quote many special and regular characters between a pair of single quotation marks: 'This is a special character: >'. The regular characters are interpreted as usual, and the shell also interprets the special characters as regular characters.

The only way to quote the erase character (CONTROL-H), the line kill character (CONTROL-U), and other control characters (try CONTROL-M) is by preceding each with a CONTROL-V. Single quotation marks and backslashes do not work. Try the following:

$ echo 'xxxxxxCONTROL-U' $ echo xxxxxxCONTROL-V CONTROL-U


Optional

Although you cannot see the CONTROL-U displayed by the second of the preceding pair of commands, it is there. The following command sends the output of echo (page 137) through a pipe (page 136) to od (see the od man page) to display CONTROL-U as octal 25 (025):

$ echo xxxxxxCONTROL-V CONTROL-U | od -c 0000000   x   x   x   x   x   x 025  \n 0000010


The \n is the NEWLINE character that echo sends at the end of its output.





A Practical Guide to Red Hat Linux
A Practical Guide to Red HatВ® LinuxВ®: Fedoraв„ў Core and Red Hat Enterprise Linux (3rd Edition)
ISBN: 0132280272
EAN: 2147483647
Year: 2006
Pages: 383

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net