I could not find an application for the form $".", though. The form $'.' can be useful to assign contents with meta-characters like \t or \n to variables. The third and fourth examples give identical results: Only the variable is expanded. In the second example, the backslash examples are expanded, but not the variable. In the first example, neither the $SHELL variable nor the backslash escapes are expanded. Please compare: $ echo 'I am using\t$SHELL.\n' This also means that a variable will be expanded in $".", but not in $'.'. String is translated and replaced, the replacement is double-quoted. The current locale is C or POSIX, the dollar sign is ignored. The expanded result is single-quoted, as if the dollar sign had notĪ double-quoted string preceded by a dollar sign ($"string") willĬause the string to be translated according to the current locale. Hexadecimal value HHHHHHHH (one to eight hex digits) The Unicode (ISO/IEC 10646) character whose value is the The hexadecimal value HHHH (one to four hex digits) Here is a more practical example of quoting special characters. To use a literal backslash, just surround it with quotes ( '\') or, even better, backslash-escape it ( \\ ). will produce the same results as if you surrounded the string with single quotes. \uHHHH the Unicode (ISO/IEC 10646) character whose value is For example: echo 2 \ 3 \> 5 is a valid inequality. \xHH the eight-bit character whose value is the hexadecimal \nnn the eight-bit character whose value is the octal value Quote type Name Meaning Example (type at shell prompt) ' The double quote The double quote ( 'quote' ) protects everything enclosed between two double quote marks except, ', ' and \.Use the double quotes when you want only variables and command substitution. The shell is waiting for you to add a second double quote ', hence the prompt dquote>. Backslash escape sequences, if present, are You need to use a pair of double quotes in your text. The wordĮxpands to string, with backslash-escaped characters replaced as specifiedīy the ANSI C standard. This syntax is not mentioned in the answers to Differences between doublequotes " ", singlequotes ' ' and backticks ´ ´ on commandline?.ĭetails on this syntax can be found in the bash(1) manpage: Words of the form $'string' are treated specially. It looks like this syntax came from the Korn shell to Zsh and Bash, and is now in POSIX (see for example the "expand sequences" line in ). In your case, there is a special quoting syntax used, namely $'.' and $".".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |