
ディレクトリ構造内の不均一なファイル/ディレクトリ権限を見つけるにはどうすればよいですか? 次のような find コマンドを使用していくつか試してみました:
find /bin ! \( -perm 777 -o -perm 776 -o -perm 775 -o -perm 774 -o -perm 773 -o -perm 772 -o -perm 771 -o -perm 770 -o -perm 760 -o -perm 750 -o -perm 740 -o -perm 730 -o -perm 720 -o -perm 710 -o -perm 700 -o -perm 600 -o -perm 500 -o -perm 400
しかし、残りの順列と-exec ls -lL {} \;
私は次のような手動作業も行っています:
ls -lL /bin | grep -v ^-rwxr-xr-x | grep -v ^-rwx--x--x | grep -v ^-rwsr-xr-x | grep -v ^-r-xr-xr-x | grep -v ^-rwxr-xr-t
しかし、残りの順列を完了する前に、再びコマンド ラインが不足します。
どちらの方法も非常に扱いにくいようです。もっと良い、より速い、より簡単な方法はありますか? 使用しているシェル (sh) とプラットフォーム (Irix 6.5.22) に制限されていることに注意してください。
答え1
実行可能ファイルをお探しですか?
find . -type f -perm /+x
いずれにせよ、/ モードはおそらくあなたの味方です...ここにマニュアル ページがあります:
-perm /mode
Any of the permission bits mode are set for the file. Symbolic modes are accepted in this form. You must specify `u', `g' or `o' if you use a symbolic mode. See the
EXAMPLES section for some illustrative examples. If no permission bits in mode are set, this test matches any file (the idea here is to be consistent with the behaviour
of -perm -000).
更新: そうですね、奇数 (実行可能な数) を探しているのかと思いましたが...
これは動作するはずです(findからの3番目のpermパラメータをまだ使用しています)
サンプルデータ:
$ ls
000 001 002 003 004 005 006 007 010 020 030 040 050 060 070 100 200 300 400 500 600 700
検索コマンド:
$ find . -type f \( -perm /u-x,g+x -o -perm /u-w,g+w -o -perm /u-r,g+r -o -perm /g-x,o+x -o -perm /g-w,o+w -o -perm /g-r,o+r -o -perm /u-x,o+x -o -perm /u-w,o+w -o -perm /u-r,o+r \) | sort
./001
./002
./003
./004
./005
./006
./007
./010
./020
./030
./040
./050
./060
./070
基本的には、グループには権限があるが所有者には権限がないファイル、またはワールドには権限があるがグループには権限がないファイル、またはワールドには権限があるが所有者には権限がないファイルを渡してください、と言っていることになります。
注: find には 3 つの perm パラメータがあります。
- パーマモード
- パーマモード
- パーマ /モード
追伸:これの価値についてはよく分かりませんが...