[ 总结 ] 删除通过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是一个很能自动产生文件的系统,日志.邮件.备份等.虽然现在硬盘廉价,我们可以有很多硬盘空间供这些文件浪费,但需求总是多方面的嘛-我就觉得让系统定时 ...
随机推荐
- 容器基础(十): 使用kubernetes部署应用
概述 使用之前的脚本(env/server.py 得到 env/server:v0.1 镜像, env/worker.py 得到 env/worker:v0.1)得到的镜像,在部署好kubernete ...
- JAVA_四大代码块_普通代码块、构造代码块、静态代码块、同步代码块。
普通代码块 在方法或语句中出现的{}里面的内容就被称为普通代码块,普通代码块和一般的语句执行顺序一样,由他们在代码中出现的次序决定,即--"先出现先执行". 但是不同的普通代码块即 ...
- 【Python】python函数每日一讲 - dir()
最近确实是有些忙,刚过了年,积攒了很多事情需要处理,所以每日一函数只能是每两天更新一篇,在这里和大家致歉. 今天我们来看一个非常重要的函数:dir() 中文说明:不带参数时,返回当前范围内的变量.方法 ...
- js中迭代元素特性与DOM中的DocumentFragment类型 笔记
JS中迭代元素特性 在需要将DOM结构序列化为XML或者HTML字符串时,多数都会涉及遍历元素的特性,这个时候attributes属性就可以派上用场. 以下代码展示了如何迭代元素的每一个特性,然后将他 ...
- 【转】cocos2dx 3.x 集成protobuf
http://www.cnblogs.com/chevin/p/6001872.html vs2013+cocos2dx 3.13.1 这篇博文是集成Lua版本的protobuf,集成C++版本的过程 ...
- 接触到的一些数据结构: LIST_ENTRY, TAILQ
双链表: LIST_ENTRY: typedef struct _LIST_ENTRY { struct _LIST_ENTRY *Flink; follow: next entry, header ...
- php 文件上传失败
使用OSX系统,在使用MAMP Pro作为虚拟服务器,并使用PHP作为后端语言进行文件上传,从临时文件夹拷贝文件的方法为 move_uploaded_file 代码如下: if($_FILES['fi ...
- Docker实战系列一:初识Docker for Windows
windows下安装Docker官网教程Install Docker for Windows Docker配置官网教程Get started with Docker for Windows
- 第五届华中区程序设计邀请赛暨武汉大学第十四届校赛 网络预选赛 A
Problem 1603 - Minimum Sum Time Limit: 2000MS Memory Limit: 65536KB Total Submit: 564 Accepted: ...
- PropertiesConfiguration的用法
PropertiesConfiguration是一个配置文件的加载工具类,封装了从配置文件里获取值并转化为基本数据类型的方法. 使用org.apache.commons.configuration2中 ...