予期したファイルが返されないことがわかりました。

予期したファイルが返されないことがわかりました。

特定の場所で大容量ファイルを見つけようとします。

コマンドが機能し、いくつかの結果を返します。

admin@tyrell:~$ sudo find /nfshome/*/.local/ -type f -size +1G -exec ls -lh {} \;
-rw-r--r-- 1 9917183 students 5.2G Jun  5  2017 /nfshome/9917183/.local/share/Trash/files/result_25.zip
-rw-r--r-- 1 9918178 students 4.0G Sep  6  2018 /nfshome/9918178/.local/share/unity3d/Asset Store-5.x/Unity Technologies/Unity EssentialsSample Projects/3D Game Kit.unitypackage
-rw-r--r-- 1 9919185 students 2.1G Mar  6  2018 /nfshome/9919185/.local/share/Trash/files/agggg.avi
-rw-r--r-- 1 9919382 students 1.7G Jan 17  2017 /nfshome/9919382/.local/share/Trash/files/MageWar.avi
-rw-r--r-- 1 9921459 students 1.8G Apr 12 11:58 /nfshome/9921459/.local/share/Trash/files/takeout-20190412T182950Z-001(1).zip
-rw-r--r-- 1 9921459 students 1.8G Apr 12 11:58 /nfshome/9921459/.local/share/Trash/files/takeout-20190412T182950Z-001.zip
-rw-r--r-- 1 9921459 students 1.4G Apr 12 11:56 /nfshome/9921459/.local/share/Trash/files/takeout-20190412T182950Z-003.zip
-rw-r--r-- 1 9921459 students 1.4G Apr 12 11:58 /nfshome/9921459/.local/share/Trash/files/takeout-20190412T182950Z-003(1).zip

ただし、サブディレクトリを追加して検索範囲を絞り込もうとすると、share/何も得られませんが、上記のすべての内容からまったく同じ結果が得られると予想しましたshare/

admin@tyrell:~$ sudo find /nfshome/*/.local/share/ -type f -size +1G -exec ls -lh {} \;
admin@tyrell:~$ 

findが最初のコマンドと同じ結果を返さないのはなぜですか?

ベストアンサー1

コマンドは、シェル以外のコマンドにのみsudo追加の権限を付与します。findしたがって、高い場所から始めると、findファイルツリーの下にダウンしてコンテンツが表示されることがあります。

しかし、シェルが拡張しようとしています*。ユーザーがスキャンしているコンテンツに対する権限を持っていないと、その中にある/nfshome/*/.localファイルを一致させることはできません(例/nfshome/*/.local/share:)。一致するものがなければ、何も渡されませんfind

echo /nfshome/*/.localsumの出力を調べるとこれを確認できますecho /nfshome/*/.local/share。 2番目の項目は空白にすることができます。

まだ明確ではないなぜ最初のコマンドが機能しているように見える場合は、2番目のコマンドを実行しようとします。サブシェルからコマンド全体を実行し、sudo.egを使用できます。sudo -c "find ..."

おすすめ記事