echo
echo - 打印一行文本到标准输出
当然它可以将输入重定向到某个文件中
实例:
oliver@ubuntu:~/temp$ echo "\"yinjianwen\""
"yinjianwen"
oliver@ubuntu:~/temp$
\
作为转义字符的作用,和C语言中是相同的
echo -e
表示开启转义
注意:"!\n"
这样的组合会被识别为一个指令组合!
oliver@ubuntu:~/temp$ echo -e "OK!\n"
bash: !\n: event not found
oliver@ubuntu:~/temp$ echo -e "OK! \n"
OK!
oliver@ubuntu:~/temp$ echo "OK! \n"
OK! \n
oliver@ubuntu:~/temp$ echo "OK! \ntest"
OK! \ntest
oliver@ubuntu:~/temp$ echo -e "OK! \ntest"
OK!
test
oliver@ubuntu:~/temp$
重定向到文件中
oliver@ubuntu:~/temp$ ls
echo.sh
oliver@ubuntu:~/temp$ echo "It is a test" > echo.sh
oliver@ubuntu:~/temp$
原样输出:
oliver@ubuntu:~/temp$ echo '$name\"'
$name\"
oliver@ubuntu:~/temp$