linux中“<”和“<<”有什么區(qū)別

linux中“<”和“<<”有什么區(qū)別

區(qū)別:

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

(推薦教程:linux教程

舉例:

1、將history命令執(zhí)行的結(jié)果保存到history.log文件中

[root@gxzs-solr1?~]#?history?&gt;?history.log??????(history.log?文件?會自動生成) [root@gxzs-solr1?~]#?cat?history.log

2、執(zhí)行命令 curl ‘xxx’ ,將其返回結(jié)果保存到 log.log 中

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

3、執(zhí)行命令 cat /etc/hosts , 將其返回結(jié)果保存到 hosts.log 中

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

注意:使用? >? ?,執(zhí)行命令時,每次都會新生成一個 > 后面的文件,將之前生成的文件替換掉(文件創(chuàng)建時間也會跟著改變)。

以上就是

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點贊5 分享