Sometimes in some service management scripts to see the $ "$string", after some tests, found that the outside of the quotation marks is the same as No. Just turned the man bash and found an explanation.
(1). If there is no special custom bash environment or special needs, $ "string" and "string" are exactly equivalent, use $ "" only to ensure localization.
Here is the man bash explanation for $ "":
A double-quoted string preceded by a dollar sign ($"string" string to is translated according to the current locale. If The current locale was C or POSIX, the dollar sign is ignored. string Double-quoted.
(2). There are $ ' string ' followed by single quotation marks, which are treated in bash Special: some backslash sequences (such as \n,\t,\ ", \ ', and so on) will be escaped without being considered literal (if there is no $ symbol, single quotation marks will force the string to be translated into literal notation, including backslashes )。 A simple example:
Echo ' A\NB ' Echo $'a\nb'ab
Here's a description of man bash about $ ':
Words of the form $'string'is treated specially. The word expands tostring, with backslash-escaped characters replaced as specified by the ANSI C standard. Backslash escape sequences,ifpresent, is decoded as follows: \a alert (Bell) \b Backspace \e \e an escape character \f form feed \ n New line \ r Carriage return \ t Horizontal tab \v vertical tab \ Backslash \
'Single Quote\"Double Quote\NNN the eight-bit character whose value is the octal value nnn (one to three digits) \xhh the eight-bit character whose value is the hexadecimal value HH (one or both hex digits) \uhhhh the Unicode (iso/iec10646) character whose value is the hexadecimal value HHHH (one to four hex digits) \uhhhhhhhh The Unicode (ISO/iec10646) character whose value is the hexadecimal value hhhhhhhh (one to eight hex digits) \cx a control-X character
Back to Linux series article outline: http://www.cnblogs.com/f-ck-need-u/p/7048359.html
Back to Site Architecture series article outline: http://www.cnblogs.com/f-ck-need-u/p/7576137.html
Back to Database series article outline: http://www.cnblogs.com/f-ck-need-u/p/7586194.html
Reprint Please specify source: http://www.cnblogs.com/f-ck-need-u/p/8451982.html
Note: If you think this article is not bad please click on the lower right corner of the recommendation, your support can inspire the author more enthusiasm for writing, thank you very much!
What is the use of quotation marks in the shell ($ "string" and "string")