find结合xargs删除特殊文件

简介:

1、需求(删除txt格式的文件)

[root@a1 temp]# ls   
hello test.txt
[root@a1 temp]# find . -type f -name "*.txt" -print | xargs rm -f
[root@a1 temp]# ls
hello test.txt

2、分析说明

因为很多文件名中都可能会包含空格符,而xargs很可能会误认为它们是定界符(例如,hello test.txt会被xargs误认为是hello和test.txt)


3、结合-print0与find使用,以字符null来分割输出

[root@a1 temp]# find . -type f -name "*.txt" -print0 | xargs -0 rm -f










本文转自 冰冻vs西瓜 51CTO博客,原文链接:http://blog.51cto.com/molewan/1703122,如需转载请自行联系原作者
目录
相关文章
|
Oracle 关系型数据库 数据库
[20171120]关于find 软连接问题.txt
[20171120]关于find 软连接问题.txt --//上个星期为了测试oracle参数filesystemio_options,将数据库做了一次移动.但是我使用find对软链接目录查询时 --//遇到一些问题做一个记录 1.
1294 0