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