免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3947 | 回复: 7
打印 上一主题 下一主题

find 命令求解(只打印最深层次目录,不打印其父目录),如果用别的命令可以做到也可以 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-05-19 12:42 |只看该作者 |倒序浏览
本帖最后由 dmidecode 于 2011-05-19 12:51 编辑

1. 以下是我使用 find 后的结果,我不希望打印最深目录的父目录,也就是红标记的目录不用打印,
2. 我想删除,如 antnlog/xlf 这个目录下 10 天前的文件,但至少要保留7个,有种可能是这个目录下有7个文件,但有3个可能是10前的,也不删,至少要保留7个!


[test@ubuntu-111 study]$ for subdir in `find antnlog/* -type d ` ; do echo $subdir ; done                                             
antnlog/xlf
antnlog/assure
antnlog/coupon
antnlog/coupon/1
antnlog/coupon/2
antnlog/coupon/3
antnlog/coupon/4
antnlog/coupon/5
antnlog/coupon/6
antnlog/coupon/0
antnlog/etc
antnlog/etc/order
antnlog/etc/refund
antnlog/etc/merchant
antnlog/etc/common
antnlog/etc/common/xlf
antnlog/etc/common/currency
antnlog/instant
antnlog/logistics
antnlog/makeorder
antnlog/opera
antnlog/order
antnlog/order/logs
antnlog/order/sys
antnlog/order/usr
antnlog/order/usr/cont

antnlog/order/usr/cont/1
antnlog/order/usr/cont/2
antnlog/precharge
antnlog/quotation
antnlog/top
antnlog/umid
antnlog/user_behavior_message

论坛徽章:
0
2 [报告]
发表于 2011-05-19 12:49 |只看该作者

论坛徽章:
0
3 [报告]
发表于 2011-05-19 12:59 |只看该作者
回复 2# ywlscpl


    谢谢! 这种变通不错,
还有第二问,呵呵 ,不知有没有什么好的变通?

论坛徽章:
0
4 [报告]
发表于 2011-05-19 13:09 |只看该作者
回复 1# dmidecode


    11个文件,6个是10天前的,怎么留?
留2删4?按什么条件删这4个

论坛徽章:
0
5 [报告]
发表于 2011-05-19 13:19 |只看该作者
http://search.chinaunix.net/bbs. ... title&forums=24

找到方法了,6个10天前的,删4个时间更早的!

论坛徽章:
3
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:51:162015年亚洲杯之阿曼
日期:2015-04-07 20:00:59
6 [报告]
发表于 2011-05-19 13:33 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
7 [报告]
发表于 2011-05-19 13:38 |只看该作者
还有一点问题,现在我这个目录下有
apache.log
apache.log_xxx
apache.log_12
apache.log_....
....

jboss.log
jboss.log_mmm
jboss.log_999
....

user.log
user.log_ddd
user.log_000
....

希望同一类型的日志至少保留7份!

论坛徽章:
0
8 [报告]
发表于 2011-05-19 14:37 |只看该作者
是不是这需求有点过份啊,怎没人帮咱了?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP