linux find depth参数理解

man find 
-depth Process each directory’s contents before the directory itself.

参数-depth 的意思是:在处理目录以前首先处理目录下的子内容。
也即是说在不加-depth的时候, 处理顺序是首先处理目录本身,然后处理目录下的子内容。加不加-depth参数,会影响输出结构的输出顺序。

-------------------------------------------------------------
例如下面的两个命令,输出结果是相反的:
先输出子内容,再输出上层目录内容,直到最顶层:
[oracle@oracledb ~]$ find test -depth  ! -empty
test/test1/test2/test3
test/test1/test2
test/test1
test

先输出顶层目录,再输出下面的各层子目录内容,直到最低层:
[oracle@oracledb ~]$ find test   ! -empty
test

test/test1
test/test1/test2
test/test1/test2/test3
---------------------------------------------------------------


去掉顶层目录test的那行输出, 加-mindepth 1(可以看到输出结果为3行,少了一会"test")。因为默认是包含顶层目录的:
[oracle@oracledb ~]$ find test -depth  -mindepth 1  ! -empty  
test/test1/test2/test3
test/test1/test2
test/test1


[oracle@oracledb ~]$ find test  -mindepth 1  ! -empty
test/test1
test/test1/test2
test/test1/test2/test3


原文:http://blog.itpub.net/27042095/viewspace-1084430/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值