目录
一、echo
echo用于输出字符串
值得关注的地方
1、转义字符\。例如,echo "\"Hello,World\" is a classic sentence for programmer"。
2、read命令用于读取一行的输入,echo可以对输入进行输出
3、\n换行,\c不换行。需要在前面加上-e才会生效。
[root@VirTrxcx test]# cat var.sh
#! /bin/bash
echo This is a simple test.
echo Now please input a number you are thinking now:
read number
echo -e "Now,I know \c"
echo -e "you are thinking ${number}, right?\n"
echo This is another.
[root@VirTrxcx test]# ./var.sh
This is a simple test.
Now please input a number you are thinking now:
20
Now,I know you are thinking 20, right?
This is another.
4、echo message > file
输出内容到文件,文件不存在会创建并写入,文件已存在则会覆盖内容。