反引号在Linux中起着命令替换的作用。命令替换是指shell能够将一个命令的标准输出插在一个命令行中任何位置。
echo The date is `date`
The date is Thu Aug 13 15:10:58 CST 2015
单引号、双引号用于把带有空格的字符串赋值给变量
str="Today is Monday"
echo $str
Today is Monday
单引号告诉shell忽略所有特殊字符
testvalue=100
echo 'the testvalue is $testvalue'
the testvalue is $testvalue
双引号忽略大多数,但不包括$、\、' 。
echo "the testvalue is $testvalue"
the testvalue is 100
反斜杠一般用于转义字符
echo要让转义字符发生作用,需要使用-e选项,且转义字符要使用双引号。
echo -e "hello\nnice to meet you"
hello
nice to meet you