「echo 」和「echo 」的區別

2022-06-10 21:57:13 字數 420 閱讀 6017

> 輸出重定向

>> 輸出追加重定向

echo hello a

將字串hello a輸出到螢幕

echo hello a > tmp.txt

將字串輸出重定向,當前目錄沒有tmp.txt,則建立tmp.txt,並將字串輸出到tmp.txt檔案中

tmp.txt內容:hello a

echo hello b > tmp.txt

將字串輸出重定向, 當前目錄存在tmp.txt,則將tmp.txt內容替換成輸出的字串

tmp.txt內容:hello b

echo hello c >> tmp.txt

將字串輸出追加重定向,當前目錄存在tmp.txt,則將tmp.txt的內容後面追加輸出的字串

tmp.txt內容:hello b hello c

echo 和 echo 的區別

在使用shell的時候,我們經常會用到echo hello temp.out和echo hello temp.out,但是 和 有什麼區別呢?且聽我慢慢道來。先建立乙個用作實驗的檔案temp.out,touch temp.out,如下圖 先使用echo hello temp.out,檢視檔案內容,繼...

「echo 」和「echo 」的區別

內容全部來自此部落格 輸出重定向 輸出追加重定向 echo hello a 將字串hello a輸出到螢幕 echo hello a tmp.txt 將字串輸出重定向,當前目錄沒有tmp.txt,則建立tmp.txt,並將字串輸出到tmp.txt檔案中 tmp.txt內容 hello a echo ...

「echo 」和「echo 」的區別

輸出重定向 輸出追加重定向 echo hello a 將字串hello a輸出到螢幕 echo hello a tmp.txt 將字串輸出重定向,當前目錄沒有tmp.txt,則建立tmp.txt,並將字串輸出到tmp.txt檔案中 tmp.txt內容 hello a echo hello b tmp...