[root@cloud abc]# touch test{,,,}
[root@cloud abc]# ls
shadow test test1 test2 test3 test5
[root@cloud abc]# rm -rf `find . -name "test*"` # 第一种方法
[root@cloud abc]# ls
shadow
[root@cloud abc]# touch test{,,,}
[root@cloud abc]# find . -name "test*" -exec rm {} \;  # 第二种方法
[root@cloud abc]# touch test{,,,}
[root@cloud abc]# find . -name "test*" | xargs rm     # 第三种方法
[root@cloud abc]# ls
shadow
[root@cloud abc]# ls
shadow test test1 test2 test3 test5
[root@cloud abc]# rm -rf `find . -name "test?"`  # 这里在扩展下,删除 查找对象+1个字符的文件。
[root@cloud abc]# ls
shadow test
[root@cloud abc]# mkdir test{..}  # 创建test1-9
[root@cloud abc]# ls
test1 test2 test3 test4 test5 test6 test7 test8 test9
[root@cloud abc]# for i in `find . -type d ! -name .`;do echo "hehe" >> $i/abc && echo "$i is success."; done  # 在每个目录下创建一个abc的文件
./test4 is success.
./test3 is success.
./test8 is success.
./test2 is success.
./test6 is success.
./test1 is success.
./test5 is success.
./test7 is success.
./test9 is success.
[root@cloud abc]# ls
test1 test2 test3 test4 test5 test6 test7 test8 test9 [root@cloud abc]# cat test{..}/abc  # 查看每个目录下文件的内容
hehe
hehe
hehe
hehe
hehe
hehe
hehe
hehe
hehe

[ 总结 ] 删除通过find查找到的文件的更多相关文章

  1. [vs2008]Visual Studio 2008 SP1添加或删除功能提示查找SQLSysClrTypes.msi文件

    前言 今天接到领导布置的一个任务,是之前同事负责的项目.离职了,现在客户有些地方需要修改,由于我之前参与过,就落在我的头上了. 然后我就把代码弄了过来,打开发现其中需要用到水晶报表.(我觉得不好用,不 ...

  2. linux 查找目录或文件详解

    查找目录:find /(查找范围) -name '查找关键字' -type d查找文件:find /(查找范围) -name 查找关键字 -print 如果需要更进一步的了解,可以参看Linux的命令 ...

  3. 【转】使用 lsof 查找打开的文件

      在 UNIX® 环境中,文件无处不在,这便产生了一句格言:“任何事物都是文件”.通过文件不仅仅可以访问常规数据,通常还可以访问网络连接和硬件.在有些情况下,当您使用 ls 请求目录清单时,将出现相 ...

  4. 文本内容查找grep、文件查找find、正则匹配

    一.文本内容查找工具 grep grep   egrep (文本过滤)   fgrep (不支持正则) 对文本的内容按照指定的匹配模式基于行来进行筛选 格式     grep [选项] 模式 文件 选 ...

  5. CentOS查找目录或文件

    查找目录:find /(查找范围) -name '查找关键字' -type d查找文件:find /(查找范围) -name 查找关键字 -print 如果需要更进一步的了解,可以参看Linux的命令 ...

  6. Linux记录-自动删除几天前的日志文件

    #!/bin/sh DDIR=/usr/local/appserver/tomcat_risk/logs/risk_manage find $DDIR -mtime +30 -name "* ...

  7. linux重命名所有find查找到的文件/文件夹

    一.说明 在某些时候我们想要将所有find命令查找到的文件或文件夹全都重命名,比如都加上.bak后辍 二.操作命令 find /dir -name "*pattern*" -exe ...

  8. 用rm递归递归删除子目录下所有.o后缀文件

    find . -name "*.o"  | xargs rm -f   可以通过管道命令来操作,先find出主目录 下想删除的文件,然后通过“xargs”这个构造参数列表并运行命令 ...

  9. Linux计划任务,自动删除n天前的旧文件

    Linux计划任务,自动删除n天前的旧文件 linux是一个很能自动产生文件的系统,日志.邮件.备份等.虽然现在硬盘廉价,我们可以有很多硬盘空间供这些文件浪费,但需求总是多方面的嘛-我就觉得让系统定时 ...

随机推荐

  1. MySQL linux错误处理

    https://cloud.tencent.com/developer/article/1023732 mysql5.7 ERROR 1045 (28000): Access denied for u ...

  2. Failed loading D:\Program Files\phpStudy20161103\php\php-5.6.27-nts\ext\php_xdebug.dll

    我用的是phpstudy 更新完composer php 切换composer的国内源的时候老是报找不到\php_xdebug.dll的错误, 原因是, 在php.ini 里面默写就是在Program ...

  3. Mapper的方式总结

    Mapper的方式总结: <mappers> <!-- 通过package元素将会把指定包下面的所有Mapper接口进行注册 --> <package name=&quo ...

  4. PAT 甲级 1002 A+B for Polynomials

    https://pintia.cn/problem-sets/994805342720868352/problems/994805526272000000 This time, you are sup ...

  5. Eclipse的优化方案

    General > Startup and Shutdown : 移除所有在启动时加载的插件. General > Editors > Text Editors > Spell ...

  6. 洛谷 P2894 [USACO08FEB]酒店Hotel 解题报告

    P2894 [USACO08FEB]酒店Hotel 题目描述 The cows are journeying north to Thunder Bay in Canada to gain cultur ...

  7. 12.25模拟赛T2

    https://www.luogu.org/blog/a23333/post-xing-xuan-mu-ni-sai-path-ji-wang-zui-duan-lu 如果设f[i]表示从i到n的期望 ...

  8. 【COGS 461】[网络流24题] 餐巾 最小费用最大流

    既然是最小费用最大流我们就用最大流来限制其一定能把每天跑满,那么把每个表示天的点向T连流量为其所需餐巾,费用为0的边,然后又与每天的餐巾对于买是无限制的因此从S向每个表示天的点连流量为INF,费用为一 ...

  9. NEYC 2017 自动取款机 atm Day6 T1

                                                                                          自动取款机 [问题描述] 小 ...

  10. 一个JavaScript反射使用的例子

    反射机制指的是程序在运行时能够获取自身的信息.例如一个对象能够在运行时知道自己有哪些方法和属性.在JavaScript中有一个很方便的语法来实现反射,即for(…in…)语句,其语法如下: 1 for ...