1. 程式人生 > >shell 中 '>' 與‘>>’ 的區別

shell 中 '>' 與‘>>’ 的區別

在shell中

'>'  為建立: echo “hello shell”  > out.txt

'>>' 為追加:echo “hello shell”  >> out.txt

當out.txt 文字不存在時,'>'與‘>>’都會預設建立out.txt文字,並將hello shell 字串儲存到out.txt中

當out.txt文字存在時,‘>’會將out.txt文字中的內容清空,並將hello shell 字串存入

                                   而‘>>’會將 hello shell追加儲存到out.txt的末尾