1. Q: sh: Can I quote '"' in a double quoted string?
I'm trying to reconcile some Bourne shell documentation (Solaris) with
Bourne shell's behavior.
The manpage says, regarding quoting:
"Inside a pair of double quote makrs (""), [...] \ quotes the
characters \, `, , and $. The pair \newline is removed before
parameter and command substitution. If a backslash precedes
characters other than \, `, , $, and newline, then the backslash
itself is quoted by the shell."
Note particularly the last sentence. This would suggest that:
$ echo " \" HELP! \" "
...would give you:
\" HELP! \"
...as output, right? This would be because a double quote mark is not
one of those characters which a backslash quotes, according to the
documentation. This seems like a load of hooey to me, because
everyone knows that if you type the example above you really get:
" HELP! "
OR: is it possible that what's going on here is the following:
1. The string consisting of three spaces, '\"', one space, 'HELP!',
one space, '\"', three spaces is quoted by the shell. Since there are
no backslashed \, `, , or $ characters, the shell protects the
whitespace and passes the string as one argument to the echo command.
Thus, echo gets
its sole arguement.
2. The subshell that echo is running under does processing on the one
argument to echo, translating the '\"' sequences to '"'.
Unless I hear otherwise, I'm going to assume that you CAN backslash a
double quote mark inside a double quoted string in the Bourne shell,
and that the documentation is simply wrong not to mention this.
laird j. nelson (617) 252-5147
nets, incorporated 25 first street
http://www.amherst.edu/~ljnelson cambridge, ma 02141
2. Can't download e-mail with Word/Excel attachments
3. Regex searches within quoted strings
4. Linux Kernel Size, POSIX, Embedded
5. Double quotes within double quotes (no apostrophes)
6. FreeSCO and Thinkpad 701C & PCMCIA CDROM
7. sending quoted strings to CGI
8. SMB and IP masquerading
9. Preserving quoted strings and literal metacharacters in lists
10. How can you find a string within a string?
11. How To Substitute (with sed) Only in Quoted Part of String?
12. Single Quote part of a string
13. String containing double quotes