Linux shell中单引号 双引号 反引号 反斜杠的区别
2015-08-13 15:40
696 查看
反引号在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
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
相关文章推荐
- Shell脚本编程-脚本格式
- 常用的shell命令汇总,夯实Linux基础
- 鸟哥的Linux学习笔记-bash
- Linux shell脚本的字符串截取
- adb shell dumpsys 命令 查看内存
- XShell安装和配置(系统为虚拟机中的centos7)
- Linux Shell脚本编程--grep命令详解
- shell 批量创建用户 并指出错误?
- remove '^M' in shell script
- Zabbix监控之Linux命令行/Shell脚本解析json
- Xshell连接CentOS问题
- 常用.bash_profile配置
- /etc/profile、~/.bash_profile等几个文件的执行过程
- 【Powershell】【DNS】通过Powershell远程注册静态DNS
- Spark入门实战系列--3.Spark编程模型(上)--概念及SparkShell实战
- 让Shell终端下的svn diff支持颜色高亮
- shell中for循环总结
- shell中单引号和双引号区别
- Shell 批量删除失效软链接
- BAPC2014 B&&HUNNU11582:Button Bashing(BFS)