LINUX 引号

引号
1、引用的必要性。
2、双引、单引和反引号。
3、使用反斜线实现屏蔽。

引用类型
1、" " 双引号, 2、` 反引号, 3、' ' 单引号, 4、 \ 反斜线

例子:
双引号:使用双引号可引用除字符$、`、\外的任意字符或字符串
echo sdfdsfsd * fsdfsdf 如果不加引号,linux就会将命令行解释为 显示目录列表
echo "date"

read myword
12345
echo $myword
echo "$myword"

单引号:与双引号类似,不同的是s h e l l会忽略任何引用值
echo '*'
read myword
12345
echo $myword  ---12345
echo '$myword' ---$myword 将内容原本输出

反引号:反引号用于设置系统命令的输出到变量。shell将反引号中的内容作为一个系统命令,并
执行其内容(tab 上面的那个键)
如: echo `date`  ---2011年 12月 08日 星期四 11:13:50 CST
echo "Today is `date`" --Today is 2011年 12月 08日 星期四 11:15:12 CST
echo "There are `who |wc -l` users on this system"  --There are 19 users on this system

反斜线:反斜线防止s h e l l误解其含义,即屏蔽其特殊含义。特殊字符: & * + ^ $ ` " | ?
echo * 与 echo \*
expr 12 \* 12  --144  echo $((8*8))
echo "This book is \$19"

猜你喜欢

转载自zhaoshunxin.iteye.com/blog/1297522