find 命令与 xargs

2019-05-09  本文已影响0人  Alexander_Zz

前提


常用参数

~]# echo "%" | xargs -0 echo > 1
~]# cat 1
%
~]# cat 1.txt 
find a test file!
~]# cat 1.txt  | xargs -E "test" echo 
find a
~]# cat 1.txt 
find a test file!
~]# cat 1.txt  | xargs -n2   echo 
find a
test file!
~]# find /data/ftpsite/pmsc/radar/latlon/single/ -type f -mtime +1 | xargs -t -i  mv {}    /data/ftpsite/pmsc/radar/latlon/history/
~]# find /data/ftpsite/pmsc/radar/latlon/single/ -type f -mtime +1 | xargs -t -i  cp  {}    /data/history/
~]# /bin/find  /data/ftpsite/pmsc/radar/latlon/single/  -type f -ctime +2 | xargs rm -rf   # 直接删除匹配到的文件,一定要指定类型,不然匹配到目录也统统删除 
~]# /bin/find /data/ftpsite/pmsc/radar/latlon/single/ -type f -mtime +2  | xargs -t -i  rm -rf  {}   # 适用于数量众多的文件删除且显示每一条执行的 shell 命令
image.png
上一篇 下一篇

猜你喜欢

热点阅读