findコマンドの便利な使い方

-maxdepth: サブディレクトリーを無視した検索

find . -maxdepth 1

-exec 結果を他のコマンドに渡す

"-type d"オプションでフォルダーのみをfind
"du -s"で合計サイズのみを表示
{}に結果が入る
\;は-execオプション終了の印

find . -type d -name sodomojo -exec du -s {} \;

-ok: 結果を他のコマンドに渡す(実行前に確認)

sodomojoというフォルダーを削除
削除前に実行するかどうかを確認してくる

find . -type d -name sodomojo -ok rm -rf {} \;

-perm: パーミッションで検索

setuidのファイルを探す

find . -perm 4755

-mtime: 一日以内にデータが更新されたファイルを検索

find . -mtime -1

-regex: 正規表現で検索

[注] 結果に完全にマッチしないといけない。

「sodomojo」から始まり「.bak」で終わらないファイル

find . -regex "\./sodomojo.*" -not -regex ".*\.tmp"
find . -regex "\./sodomojo.*" ! -regex ".*\.tmp"