linux中 > 、>> 的用法

linux中>表示覆盖原文件内容(文件的日期也会自动更新),>>表示追加内容(会另起一行,文件的日期也会自动更新)。

 

1 将history命令执行的结果保存到history.log文件中

 

 

2 执行命令 curl 'xxx' ,将其返回结果保存到 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 执行命令 cat /etc/hosts , 将其返回结果保存到 hosts.log 中

 

注意:
使用  >   ,执行命令时,每次都会新生成一个 > 后面的文件,将之前生成的文件替换掉(文件创建时间也会跟着改变)。

 

4 使用 >> 向 hosts.log中追加 当前日期

[root@slave1 ~]# echo "当前日期是 `date`" >> hosts.log

 

 

 原文出处:https://blog.csdn.net/wudinaniya/article/details/84846732

 

posted @ 2019-11-19 11:47  sucre_tan  阅读(1359)  评论(0编辑  收藏  举报