6. Shell echo命令
-
echo hello world
显示转移字符
echo "\"hello world\""
echo \"hello world\"
结果:
"hello world"
显示变量
reed命令从标准输入中读取一行,并把输入行的每个字段的值指定给shell变量:read name
显示换行
echo -e "OK! \n" # -e 开启转义
echo It is a test
输出结果:
OK!
It is a test
显示不换行
# !/bin/sh
OK! It is a test
显示结果定向至文件
原样输出字符串,不进行转义或取变量(用单引号)
echo '$name\"'
输出结果:
$name\"
-
echo `date`
注意:这里使用的是 反引号 `,而非单引号。
输出结果显示当前日期:asa-virtual-machine:~$ echo `date`