Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Shells: User's Guide: HP 9000 Computers > Chapter 17 Shell Grammar

Quoting

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

Each of the metacharacters discussed above can be quoted, or protected, to make it stand for itself and not be interpreted by the shell as a special character. Table 17-3 “Quoting Metacharacters”, lists, and gives examples using, these metacharacters.

Table 17-3 Quoting Metacharacters

Meta- character

Example

Description

\

$ ls prog.\*
prog.*

The backslash \ cancels the special meaning of the metacharacter that follows it. (Note that the backslash is not special inside single quotes.) The backslash forces ls to list the file actually named prog.*, not all files starting with prog..

'

$ echo '$PWD'
$PWD
$ echo '\$PWD'
\$PWD

The single quote (') protects everything enclosed between two single quote marks except the single quote itself. That is, only the single quote can't be protected; all other metacharacters have no special meaning inside single quotes.

"

$ echo "$PWD"
/users/mary
$ echo "\$PWD"
$PWD

The double quotes allow parameter and command substitution. The \, inside double quotes, quotes the characters \, ', ", and $ rather than the shell evaluating them. This example echos the path name contained in the variable PWD. When the \ is placed in front of the $, the echo cannot evaluate PWD.

 

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-1991 Hewlett-Packard Development Company, L.P.