1
0

【Linux】特定のディレクトリを除外して特定の拡張子のファイルの権限を変更する

Posted at

以下のようなディレクトリ構成があるとする。
dir
┗subdir1
 ┗file1.txt
┗subdir2
 ┗file2.txt
┗subdir3
 ┗file3.txt
┗file4.txt

このうち、subdir1、subdir2以外にある、.txtの拡張子を持つファイルに対して755権限を付与する。

find ${path} -type f -name "*.txt" ! -path "${path}subdir1/*" ! -path "${path}subdir2/*" -exec chmod 755 {} \;

この場合、file3.txtとfile4.txtが対象になる。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0