[ 总结 ] 删除通过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是一个很能自动产生文件的系统,日志.邮件.备份等.虽然现在硬盘廉价,我们可以有很多硬盘空间供这些文件浪费,但需求总是多方面的嘛-我就觉得让系统定时 ...
随机推荐
- 有关于PHP的基础知识
(1) l 长字符串表示,必须放在“<<<heredoc”和 “heredoc;”之间.主要是<<<,其次是也可以不使用heredoc. l “<< ...
- 一个python游戏源码
#finalPyPong.py import pygame,sys class MyBallClass(pygame.sprite.Sprite): def __init__(self,image_f ...
- Java中动态代理实现原理深究
一.前言 笔者平时开发使用“动态代理”不多,最近在看设计模式的时候,“动态代理”又在面前晃了几次,所以这次想从源码的角度去分析动态代理的实现原理,以窥探其精妙~ 二.正文 2.1 静态代理 本文源码 ...
- HDFS集群和YARN集群
Hadoop集群环境搭建(一) 1集群简介 HADOOP集群具体来说包含两个集群:HDFS集群和YARN集群,两者逻辑上分离,但物理上常在一起 HDFS集群: 负责海量数据的存储,集群中的角色主要 ...
- BZOJ4513 SDOI2016储能表(数位dp)
如果n.m.k都是2的幂次方,答案非常好统计.于是容易想到数位dp,考虑每一位是否卡限制即可,即设f[i][0/1][0/1][0/1]为第i位是/否卡n.m.k的限制时,之前的位的总贡献:g[i][ ...
- hdu 1286 找新朋友 (欧拉函数)
找新朋友 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- 洛谷 P3143 [USACO16OPEN]钻石收藏家Diamond Collector 解题报告
P3143 [USACO16OPEN]钻石收藏家Diamond Collector 题目描述 Bessie the cow, always a fan of shiny objects, has ta ...
- table表头固定问题
table表头固定问题 原生的table表头在表格滚动时候无法固定,可以使用以下的方法进行模拟 1. 双table法 表头和表体各用一个table,这样会产生表格列对不齐的问题,可以使用colgrou ...
- 牛客 国庆七天乐 day1 L
https://www.nowcoder.com/acm/contest/201/L 题意:给你两条平行的直线和n个圆,在直线上面行走和在圆上和在圆内行走不需要耗费体力,除了这些区域外平面上经过任意两 ...
- hadoop更换硬盘
hadoop服务器更换硬盘操作步骤(datanode hadoop目录${HADOOP_HOME}/bin 日志位置:/var/log/hadoop)1.登陆服务器,切换到mapred用户,执行 ...