首页  >  文章  >  运维  >  linux中“<”和“<<”有什么区别

linux中“<”和“<<”有什么区别

王林
王林转载
2020-07-20 17:31:076137浏览

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删除