What is the use of the shell after $ after quotes ($ "string" and "string")

Source: Internet
Author: User
Tags locale

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")

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.