【问题标题】:How to limit the depth of the directory visited by the Unix command find?如何限制Unix命令find访问的目录深度?
【发布时间】:2018-05-06 07:04:53
【问题描述】:

已经提出了类似的问题,但我对答案不满意。确实,我想使用 Unix find 命令,而我使用的 find 命令不允许选项 -maxdepth。但是,有一个选项 -depth 但我没有成功地以我满意的方式使用它。我使用 ksh shell。

【问题讨论】:

标签: shell unix find ksh


【解决方案1】:

如果你像这个例子一样添加grep命令,你可以限制列表:

find $mydir -name "BILL_*.pdf" | grep "$mydir/BILL"

祝你好运……

【讨论】:

    【解决方案2】:

    参考find manual

    -depth  Always evaluates to the value True. Causes the descent of the  
    directory hierarchy to be done so that all entries in a directory are 
    affected before the directory itself is affected. It can be useful    
    when the find command is used with the cpio command to transfer files 
    that are contained in directories without write permission.   
    

    所以它不接受参数。

    【讨论】:

    • 是的,但是这个选项不能帮助 find 命令只处理给定数量的深度级别。
    猜你喜欢
    • 1970-01-01
    • 2019-05-20
    • 1970-01-01
    • 2013-03-30
    • 1970-01-01
    • 2012-12-09
    • 2011-04-21
    • 2011-05-11
    • 2021-12-05
    相关资源
    最近更新 更多