Shell 的 echo 指令与 PHP 的 echo 指令类似,都是用于字符串的输出。
比如
echo "It is a test"
It is a test
它也可以通过与>符号配合将内容写入文件
echo 'add content'>>/home/data/test.sh
>> 是追加 是在文件后追加内容
echo 'add content'>/home/data/test.sh
> 是删除原有内容后,并写入自己当前的内容
也可以通过-e符号来插入转义字符,比如
echo -e "hello\nworld" >> temp.txt
cat temp.txt
输出
hello
world