赞
踩
echo 用于字符串的输出,命令格式如下:
echo string
- echo "It is a test"
- # 二者效果一致
- echo It is a test
- echo "\"It is a test\""
- #输出 "It is a test"
read 命令从标准输入中读取一行,并把输入行的每个字段的值指定给 shell 变量
- read name
- echo "$name It is a test"
保存以上代码为 test.sh,name 接收标准输入的变量,结果将是:
- $ sh test.sh
- OK #标准输入
- OK It is a test #输出
- echo -e "OK! \n" # -e 开启转义
- echo "It is a test"
输出结果:
- OK!
-
- It is a test
- echo -e "OK! \c" # -e 开启转义 \c 不换行
- echo "It is a test"
输出结果:
OK! It is a test
echo "It is a test" > myfile
- echo '$name\"'
- # 输出 $name\"
- echo `date`
- # 结果显示当前日期
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。