Basically, when the shell see the first single quote, it ignores any special characters (white space is also a special character) until it finds another single quote (closing quotes). Ignoring all special characters All special characters lose their meaning if they are enclosed in single quotes....
Double quotes in bash will suppress special meaning of every meta characters except "$", "\" and "`". Any other meta characters will be read literally. It is also possible to use single quote within double quotes. If we need to use double quotes within double quotes bash can read them ...
'string':single quoted string,不进行转义,变量expansion “string”:double quoted string,进行转义,变量expansion $'string':访问一些特殊字符,如$'\a', $'\n' $"string":locale specific translation,translated according to the current locale 2. 注释 以#开头的行均为注释,除了第一行: #!/bin/bash 3....
full quoting [single quote]. 'STRING' preserves all special characters within STRING. This is a stronger form of quoting than "STRING". 在单引号中,所有的特殊字符豆浆失去其特殊含义。这样也就导致在单引号中无法表示单引号字符本身。 man bash QUOTING 写道 Enclosing characters in single quotes preserves...
这里主要讲的是$'string'特殊格式,注意的是,必须是单引号。它被扩展为string,其中的反斜杠转义字符被替换为 ANSI C 标准中规定的字符。反斜杠转义序列,如果存在的话,将做如下转换: 转义含义 \aalert (bell) 响铃 \bbackspace 回退 \ean escape character 字符 Esc ...
Since there's no space between the two literal parts of the string and the "$b", bash puts the final result into a single string and then assigns it to a.One place where quoting problems often occur is when you're dealing with files that have spaces in their names. For example, if...
Quotes instruct the shell how to interpret an input string. This tutorial clarifies the difference between single and double quotes in bash.
?...'string' 单引号 (single quote) 被单引号用括住的内容,将被视为单一字串。在引号内的代表变数的$符号,没有作用,也就是说,他被视为一般符号处理,防止任何变量替换。...fdv=`date +%F`还有另外一种写法就是fdv=$(date +%F),两个命令是等价的,只是反单引号(``)容易被看穿('')单引号而已...
来自bash的手册页:单引号之间不能出现单引号,即使前面有反斜杠。
3.1.2.2 Single Quotes Enclosing characters in single quotes (‘'’) preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash. 单引号包围的字符保留了在引号里面每个字符的字面意义。在单引号之间不允许出现...