The Shell's Quote Characters

Four characters are used for quoting. They turn off (or "escape") special character meanings:

  • A backslash (\) turns off the special meaning of the following character.

  • Single quotes ('…') turn off the special meaning of the characters between the quotes, except that !event still indicates history substitution.

  • Double quotes ("…") turn off the special meaning of the characters between the quotes, except that !event, $var, and `cmd` still indicate history, variable, and command substitution. (You can think of double quotes as being "weaker" than single quotes because they turn off fewer special characters.)

  • The lnext ("literal next") character turns off the special meaning of the following character.[20] This character can be used with special characters that are otherwise interpreted as soon as they are typed. For example, in tcsh a TAB triggers filename completion; therefore, you cannot type a literal TAB unless you precede it with CTRL-V.

Quoting the Quote Characters

The quote characters can be used to type literal quote characters, not simply to turn off the special meaning of other special characters.

Backslash and CTRL-V quote themselves. In other words, \\ produces \ and CTRL-V CTRL-V produces CTRL-V.

Single and double quote marks quote each other:

% echo "'" '"'
' "

Backslash quotes quote marks:

% echo \' \"
' "

And quote marks quote backslashes:

% echo '\' "\"
\ \

The following sections describe several practical methods of using the quote characters.

Get Using csh & tcsh now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.