【问题标题】:Accessing files within contained directories访问包含目录中的文件
【发布时间】:2013-06-21 04:33:30
【问题描述】:

如果我要尝试更改目录中特定文件类型的权限,例如

    chmod ugo-w *.filetype

如何对包含目录中的所有文件也执行此操作?

【问题讨论】:

    标签: bash directory subdirectory


    【解决方案1】:

    使用 find 和 xargs:

    find . -type f -name '*.filetype' | xargs chmod ugo-w
    

    如果不是当前目录,则将.替换为目录名称。

    或者,只需使用find

    find . -type f -name '*.filetype' -exec chmod ugo-w '{}' '+'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-23
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 2015-12-20
      • 1970-01-01
      • 1970-01-01
      • 2013-06-21
      相关资源
      最近更新 更多