[ 总结 ] 删除通过find查找到的文件
[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查找到的文件的更多相关文章
- [vs2008]Visual Studio 2008 SP1添加或删除功能提示查找SQLSysClrTypes.msi文件
前言 今天接到领导布置的一个任务,是之前同事负责的项目.离职了,现在客户有些地方需要修改,由于我之前参与过,就落在我的头上了. 然后我就把代码弄了过来,打开发现其中需要用到水晶报表.(我觉得不好用,不 ...
- linux 查找目录或文件详解
查找目录:find /(查找范围) -name '查找关键字' -type d查找文件:find /(查找范围) -name 查找关键字 -print 如果需要更进一步的了解,可以参看Linux的命令 ...
- 【转】使用 lsof 查找打开的文件
在 UNIX® 环境中,文件无处不在,这便产生了一句格言:“任何事物都是文件”.通过文件不仅仅可以访问常规数据,通常还可以访问网络连接和硬件.在有些情况下,当您使用 ls 请求目录清单时,将出现相 ...
- 文本内容查找grep、文件查找find、正则匹配
一.文本内容查找工具 grep grep egrep (文本过滤) fgrep (不支持正则) 对文本的内容按照指定的匹配模式基于行来进行筛选 格式 grep [选项] 模式 文件 选 ...
- CentOS查找目录或文件
查找目录:find /(查找范围) -name '查找关键字' -type d查找文件:find /(查找范围) -name 查找关键字 -print 如果需要更进一步的了解,可以参看Linux的命令 ...
- Linux记录-自动删除几天前的日志文件
#!/bin/sh DDIR=/usr/local/appserver/tomcat_risk/logs/risk_manage find $DDIR -mtime +30 -name "* ...
- linux重命名所有find查找到的文件/文件夹
一.说明 在某些时候我们想要将所有find命令查找到的文件或文件夹全都重命名,比如都加上.bak后辍 二.操作命令 find /dir -name "*pattern*" -exe ...
- 用rm递归递归删除子目录下所有.o后缀文件
find . -name "*.o" | xargs rm -f 可以通过管道命令来操作,先find出主目录 下想删除的文件,然后通过“xargs”这个构造参数列表并运行命令 ...
- Linux计划任务,自动删除n天前的旧文件
Linux计划任务,自动删除n天前的旧文件 linux是一个很能自动产生文件的系统,日志.邮件.备份等.虽然现在硬盘廉价,我们可以有很多硬盘空间供这些文件浪费,但需求总是多方面的嘛-我就觉得让系统定时 ...
随机推荐
- scrapy学习-爬取天天基金网基金列表
目录 描述 环境描述 步骤记录 创建scrapy项目 设置在pycharm下运行scrapy项目 分析如何获取数据 编写代码 step 1:设置item step 2:编写spider step 3: ...
- 使用 TListView 控件(2)
本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, ...
- adoop集群动态添加和删除节点
hadoop集群动态添加和删除节点说明 上篇博客我已经安装了Hadoop集群(hadoop集群的安装步骤和配置),现在写这个博客我将在之前的基础上进行节点的添加的删除. 首先将启动四台机器(一主三从) ...
- 计蒜客16495 Truefriend(fwt)
#include <iostream> #include <cstring> #include <cstdio> using namespace std; type ...
- 如何在自家厨房里制作LSD
如何在自家厨房里制作LSD -------------------------------------------------------------------------------- D-麦角酸 ...
- 容器(vector)、数组、new创建的动态数组,你到底用哪一个(执行效率分析)
1.问题的提出 在没有了解vector之前,动态数组一般都是又new创建的.在了解vector后发现vector竟是那样方便好用,但方便的同时却是以牺牲执行效率为代价的.网上对vector和array ...
- BZOJ1452 [JSOI2009]Count 【树套树 (树状数组)】
1452: [JSOI2009]Count Time Limit: 10 Sec Memory Limit: 64 MB Submit: 2693 Solved: 1574 [Submit][St ...
- ExtJS 4.1 TabPanel动态加载页面并执行脚本【转】
ExtJS 4.1 TabPanel动态加载页面并执行脚本 按照官方示例,可以动态加载页面,可是脚本不执行,于是查SDK.google,发现scripts需要设置为true,于是设置该属性,整个代码如 ...
- ng双向数据绑定
http://blog.csdn.net/callmekongkong/article/details/54601585
- bzoj 1201[HNOI2005]数三角形 1202 [HNOI2005]狡猾的商人 暴力 权值并查集
[HNOI2005]数三角形 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 349 Solved: 234[Submit][Status][Disc ...