[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. Hexo 博客部署到 GitHub

    本文简单记录了一下把 Hexo 部署到 GitHub 上的过程,也是搭建静态博客最常用的一种方式. 前面写了关于如何把 Hexo 安装在树莓派上的教程,但树莓派毕竟是连着自己的家的路由器,万一哪天网断 ...

  2. windows下git hub的GUI软件配置与使用

    转载自:http://www.cnblogs.com/haore147/p/3618930.html   1. 安装两个软件 1 2 1. git的命令行程序--git for windows:htt ...

  3. Ext.Net学习网站

    1.http://ext.net/ 官网.里面的examples是宝贝. 2.http://www.qeefee.com/zt-extnet 起飞网

  4. Nginx+tomcat+redis集群共享session实现负载均衡

    1.nginx是一款轻量级兼备高性能的Http和反向代理服务器.所谓反向代理就是指用户发起访问请求,由代理服务器接受,然后将请求转发给正式服务器,并且将正式服务器处理完的数据返回给客户单,此时代理服务 ...

  5. Cocoa & OS X & swift 4

    Cocoa & OS X & swift 4 http://www.runoob.com/swift/swift-environment.html https://en.wikiped ...

  6. [剑指Offer] 18.二叉树的镜像

    题目描述 操作给定的二叉树,将其变换为源二叉树的镜像. 输入描述: 8 / \ 6 10 / \ / \ 5 7 9 11 镜像二叉树 8 / \ 10 6 / \ / \ 11 9 7 5 [思路1 ...

  7. 批处理之SET命令

    除了 下面分别介绍: 表示第二个字符到倒数第三个字符的值

  8. 设置select和option的文字居中的方法

    给select设置text-align:center在火狐浏览器下ok,但是在chrome浏览器无效,然后option在两个浏览器下设置text-align:center都是无效的,解决方法,设置样式 ...

  9. C#中的SubString()的用法

    先看语法: String.SubString(int index,int length)     index:开始位置,从0开始       length:你要取的子字符串的长度 例子: using ...

  10. Codeforces Round #553 F Sonya and Informatics

    题目 题目大意 给定一个长为 $n$($2 \le n \le 100$)的01串 $S$ .对 $S$ 进行 $k$($1 \le k \le 10^9$)次操作:等概率地选取两个下标 $i, j$ ...