Shell echo命令,shellecho命令


显示变量 read 命令从标准输入中读取一行,并把输入行的每个字段的值指定给 shell 变量
#!/bin/sh
read name 
echo "$name It is a test"
以上代码保存为 test.sh,name 接收标准输入的变量,结果将是:
[root@www ~]# sh test.sh
OK                     # 标准输入
OK It is a test        # 输出
显示换行
echo -e "OK! \n" # -e 开启转义
echo "It it a test"
输出结果:
OK!
It it a test
显示不换行
#!/bin/sh
echo -e "OK! \c" # -e 开启转义 \c 不换行
echo "It is a test"
输出结果:
OK! It is a test
显示命令执行结果
echo `date`
注意: 这里使用的是反引号 `, 而不是单引号 '。 结果将显示当前日期
2017年 08月 08日 星期二 21:08:23 CST

相关内容