區(qū)別:
linux中>表示覆蓋原文件內(nèi)容(文件的日期也會(huì)自動(dòng)更新),>>表示追加內(nèi)容(會(huì)另起一行,文件的日期也會(huì)自動(dòng)更新)。
(推薦教程:linux教程)
舉例:
1、將history命令執(zhí)行的結(jié)果保存到history.log文件中
[root@gxzs-solr1 ~]# history > history.log (history.log 文件 會(huì)自動(dòng)生成) [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&contentType=text/plain;charset=utf-8&file=managed-schema&wt=json' > log.log
3、執(zhí)行命令 cat /etc/hosts , 將其返回結(jié)果保存到 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
注意:使用 > ,執(zhí)行命令時(shí),每次都會(huì)新生成一個(gè) > 后面的文件,將之前生成的文件替換掉(文件創(chuàng)建時(shí)間也會(huì)跟著改變)。
文章標(biāo)題:linux中“<”和“<<”有什么區(qū)別
網(wǎng)站地址:http://weahome.cn/article/cjgsjs.html