Shell 中的反引号(`),单引号('),双引号(")
2017-06-19 13:38
302 查看
在写shell的时候老是傻傻分不清楚,今天来理一理。
1.反引号位 (`) 位于键盘的Tab键的上方、1键的左方。注意与单引号(')位于Enter键的左方的区别。
在Linux中起着命令替换的作用。命令替换是指shell能够将一个命令的标准输出插在一个命令行中任何位置。
如下,shell会执行反引号中的date命令,把结果插入到echo命令显示的内容中。
The date is 2011年 03月 14日 星期一 21:15:43 CST
2.单引号、双引号用于用户把带有空格的字符串赋值给变量事的分界符。
Today is Monday
如果没有单引号或双引号,shell会把空格后的字符串解释为命令。
3. 单引号和双引号的区别。单引号告诉shell忽略所有特殊字符,而双引号忽略大多数,但不包括$、\、`。
1.反引号位 (`) 位于键盘的Tab键的上方、1键的左方。注意与单引号(')位于Enter键的左方的区别。
在Linux中起着命令替换的作用。命令替换是指shell能够将一个命令的标准输出插在一个命令行中任何位置。
如下,shell会执行反引号中的date命令,把结果插入到echo命令显示的内容中。
[root@localhost sh]# echo The date is `date`
The date is 2011年 03月 14日 星期一 21:15:43 CST
2.单引号、双引号用于用户把带有空格的字符串赋值给变量事的分界符。
[root@localhost sh]# str="Today is Monday" [root@localhost sh]# echo $str
Today is Monday
如果没有单引号或双引号,shell会把空格后的字符串解释为命令。
[root@localhost sh]# str=Today is Monday bash: is: command not found
3. 单引号和双引号的区别。单引号告诉shell忽略所有特殊字符,而双引号忽略大多数,但不包括$、\、`。
[root@localhost sh]# testvalue=100 [root@localhost sh]# echo 'The testvalue is $testvalue' The testvalue is $testvalue [root@localhost sh]# echo "The testvalue is $testvalue" The testvalue is 100
相关文章推荐
- shell 双引号"" 单引号'' 反引号`` 的区别
- shell中的单引号字符' 双引号字符" 反斜杠字符/ 反引号字符`
- Shell十三问之四:""(双引号)与' '(单引号)差在哪
- shell中的单引号'' 双引号"" 反引号``
- Shell中的反引号、单引号与双引号的用法(` /''/"")
- shell可以识别4种不同类型的引字符号: 单引号字符' 双引号字符" 反斜杠字符\ 反引号字符`
- SHELL的单引号'',双引号"",及$字符单双引号及字符转义的小结
- shell可以识别4种不同类型的引字符号: 单引号字符' 双引号字符" 反斜杠字符\ 反引号字符`
- 转载:shell单引号字符' 双引号字符" 反斜杠字符/ 反引号字符
- shell十三问-4) " "(双引号) 与 ' '(单引号)差在哪
- python单引号(')、双引号(")、三引号(''',""")
- shell单引号、双引号和反引号的区别
- [Ruby笔记]7.ruby -e ' " 单引号、双引号对比
- 双引号" "和单引号' '区别
- 在Shell中引号分为3种:单引号,双引号和反引号。
- Shell| 关于双引号,单引号,倒引号的使用和区别(",',`)
- " "(双引号)与 ' '(单引号)的区别 (转载)
- Linux 学习-" "(双引号)与 ' '(单引号)的区别
- jquery中$('form').submit()和$("form").submit()有什么区别?注意一个是双引号,一个是单引号
- Linux-Shell脚本中单引号和双引号区别