首頁  >  文章  >  運維  >  linux中「<」和「<<」有什麼區別

linux中「<」和「<<」有什麼區別

王林
王林轉載
2020-07-20 17:31:076136瀏覽

linux中「<」和「<<」有什麼區別

區別:

linux中>表示覆蓋原始檔案內容(檔案的日期也會自動更新),>>表示追加內容(會另起一行,文件的日期也會自動更新)。

(推薦教學:linux教學

範例:

1、將history指令執行的結果儲存到history.log檔中

[root@gxzs-solr1 ~]# history > history.log      (history.log 文件 会自动生成)
[root@gxzs-solr1 ~]# cat history.log

2、執行指令curl 'xxx' ,將其回傳結果儲存到log.log 中

[root@gx-solr1 ~]# curl &#39;http://192.168.0.110:8983/solr/scan_detail/admin/file?_=1544066402749&contentType=text/plain;charset=utf-8&file=managed-schema&wt=json&#39; > log.log

3、執行指令cat /etc/hosts , 將其傳回結果儲存到hosts.log中

[root@slave1 ~]# cat /etc/hosts > hosts.log
[root@slave1 ~]# more hosts.log 
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

注意:使用  >   ,執行指令時,每次都會新產生一個> 後面的文件,將先前產生的文件替換掉(文件建立時間也會跟著改變)。

以上是linux中「<」和「<<」有什麼區別的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:csdn.net。如有侵權,請聯絡admin@php.cn刪除