centos備文件腳本

創建x.sh文件,編輯

 

在/var/log/下查找log文件,複製文件到/home/omc/ftl且把結果保存到/home/omc/ftl/logs.txt文件中 

[root@localhost log]# find /var/log/*.log -type f | xargs -i cp {} /home/omc/ftl

[root@localhost log]# ll -ltr /home/omc/ftl

[root@localhost log]# find /var/log/*.log -type f > /home/omc/ftl/logs.txt

[root@localhost log]# ll /home/omc/ftl/logs.txt 

 

刪除 /home/omc/ftl/下的log文件 

[root@localhost ftl]# ll *.log |xargs rm -rf {} 【錯誤】

[root@localhost ftl]# ls *.log |xargs rm -rf {} 【正確】 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章