码迷,mamicode.com
首页 > 系统相关 > 详细

Linux Shell中的反引号,单引号,双引号

时间:2015-07-09 17:40:06      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:

  反引号位 (`) 位于键盘的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
  
  单引号、双引号用于用户把带有空格的字符串赋值给变量事的分界符。
  [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
  单引号和双引号的区别。单引号告诉shell忽略所有特殊字符,而双引号忽略大多数,但不包括$、\、`。
  [root@localhost sh]# testvalue=100
  [root@localhost sh]# echo ‘The testvalue is $testvalue‘
  The testvalue is $testvalue

 

  Refer:http://blog.163.com/wunan_23/blog/static/19556232020127137818151/

Linux Shell中的反引号,单引号,双引号

标签:

原文地址:http://www.cnblogs.com/edisonxiang/p/4633668.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!