Quoting, Using the backslash ( \ ), Using single quotes (' ') – HP NonStop G-Series User Manual

Page 38: Using double quotes ( " " ), Filename completion, Shell-quoting conventions

Advertising
background image

Quoting

Reserved characters are characters such as < > |& ? and *. Reserved characters have special
meanings to the shell. To use a reserved character literally (that is, without its special meaning to
the shell), “quote” the character by using one of the shell-quoting conventions, as shown in

Table 6

.

Table 6 Shell-Quoting Conventions

Description

Convention

Backslash character. Quotes a single character.

\

Single quotes. Quotes a string of characters (except the single quotation marks themselves).

' '

Double quotes. Quotes a string of characters, except any $ (dollar sign), ' (single quote), or \
(backslash).

" "

Using the Backslash ( \ )

To quote a single character, place a \ (backslash) immediately before that character, as in the
following:

$ echo \`

`

This command displays a single ` (grave accent) character.

Using Single Quotes (' ')

When you enclose a string of characters in single quotes, the shell takes every character in the
string (except the single quotes themselves) literally. Single quotes are useful when you do not wish
the shell to interpret the following:

Reserved characters such as $ (dollar sign), ` (grave accent), and \ (backslash) with their
special meanings

Variable names

The following example shows how single quotes are used when you wish to display a variable
name without having it interpreted by the shell:

$ echo 'The value of $USER is' $USER

The value of $USER is amy

The echo command displays the variable name $USER as is when it appears within single quotes,
but the command interprets the value of $USER when it appears outside the single quotes.

Using Double Quotes ( " " )

Double quotes provide a special form of quoting. Within double quotes, the reserved characters
$

(dollar sign), ` (grave accent), and \ (backslash) keep their special meanings. The shell interprets

literally all other characters within the double quotes. Double quotes are most frequently used in
variable assignments.

The following example shows how double quotes are used when you wish to display angle brackets
(normally reserved characters) in a message containing the value of the shell variable:

$ echo "<<Current shell is $SHELL>>"

<<Current shell is /bin/sh>>

Filename Completion

The OSS shell supports filename completion on the command line; that is, the OSS shell automatically
matches and completes filenames that you enter only partially on the command line. If there is

38

The OSS Shell

Advertising
This manual is related to the following products: