linux find exec rm
来源:互联网 发布:制作淘宝无缝拼接主图 编辑:程序博客网 时间:2024/05/16 05:41
#find ... -exec rm {} /;
#find ... | xargs rm -rf
# remove files older than 2 days
set +e
find $DW_LAND/dw_cbt -name "dw_cbt_apac_finance_*" -mtime +1 -exec rm {} \;
rcode=$?
set -e
两者都可以把find命令查找到的结果删除,其区别简单的说是前者是把find发现的结果一次性传给exec选项,这样当文件数量较多的时候,就可能会出现“参数太多”之类的错误,相比较而言,后者就可以避免这个错误,因为xargs命令会分批次的处理结果。这样看来,“find ... | xargs rm -rf”是更通用的方法,推荐使用!
rm不接受标准输入,所以不能用find / -name "tmpfile" |rm
-exec 必须由一个 ; 结束,而因为通常 shell 都会对 ; 进行处理,所以用 /; 防止这种情况。
{} 可能需要写做 '{}',也是为了避免被 shell 过滤
find ./ -type f -exec grep iceskysl {} /dev/null /;
./表示从当前目录找
-type f,表示只找file,文件类型的,目录和其他字节啥的不要
-exec 把find到的文件名作为参数传递给后面的命令行,代替{}的部分
-exec后便跟的命令行,必须用“ /;”结束
#find ./ -type f -name "*.cpp"|xargs grep "test" -n
#find . -name "*cpp" -exec grep "test" {} /; -print
#find ... | xargs rm -rf
# remove files older than 2 days
set +e
find $DW_LAND/dw_cbt -name "dw_cbt_apac_finance_*" -mtime +1 -exec rm {} \;
rcode=$?
set -e
两者都可以把find命令查找到的结果删除,其区别简单的说是前者是把find发现的结果一次性传给exec选项,这样当文件数量较多的时候,就可能会出现“参数太多”之类的错误,相比较而言,后者就可以避免这个错误,因为xargs命令会分批次的处理结果。这样看来,“find ... | xargs rm -rf”是更通用的方法,推荐使用!
rm不接受标准输入,所以不能用find / -name "tmpfile" |rm
-exec 必须由一个 ; 结束,而因为通常 shell 都会对 ; 进行处理,所以用 /; 防止这种情况。
{} 可能需要写做 '{}',也是为了避免被 shell 过滤
find ./ -type f -exec grep iceskysl {} /dev/null /;
./表示从当前目录找
-type f,表示只找file,文件类型的,目录和其他字节啥的不要
-exec 把find到的文件名作为参数传递给后面的命令行,代替{}的部分
-exec后便跟的命令行,必须用“ /;”结束
#find ./ -type f -name "*.cpp"|xargs grep "test" -n
#find . -name "*cpp" -exec grep "test" {} /; -print
阅读全文
0 0
- linux find exec rm
- linux find exec rm
- linux find exec rm
- linux 批量删除 find exec rm
- Linux命令之find exec rm
- find . -name -exec rm {} \;
- find exec rm
- find exec rm
- find -size -100 -exec rm {} /;
- find -name *lastUpdated -exec rm {} \;
- find . -name "11*" -exec rm -rf {} /;
- find . -name "*ab*" -exec rm -f {}\;
- find / -type f -name *fetion* -exec rm {} \;
- linux find -exec 用法
- Linux find 命令-exec
- Linux find -exec
- Linux find exec 记录
- find exec linux
- tensorflow53 《面向机器智能的TensorFlow实战》笔记-05-01 卷积基础
- fl2440串口编程
- Java Web----实训项目第一阶段
- 创建位图索引
- cxf发布rest风格的webService
- linux find exec rm
- 在linux发布网上商城案例
- Unity ResUpdater研究使用1
- Linux特训之vi编辑器part 1(基本操作)
- 面向对象中的String
- myeclipse或eclipse引入mybatis
- 最长公共子序列问题(LCS)
- python中的reduce函数
- 高通源码下载2----用从高通下载的repo