findコマンドの使い方

1,名前で検索
find -name "MyCProgram.c"


2,名前で検索(大文字小文字を区別しない)
find -iname "MyCProgram.c"


3,検索するフォルダの階層を指定する
find -mindepth 3 -maxdepth 5 -name passwd


4,検索したファイルに対してコマンドを実行
find -iname "MyCProgram.c" -exec md5sum {} \;


5,一致しないものを検索
find -not -iname "MyCProgram.c"


6,node numberで検索
find -inum 16187430


7,パーミッションで検索
find . -perm g=r -type f -exec ls -l {} \;
find . -perm 040 -type f -exec ls -l {} \;


8,空のファイルを検索
find . -empty


9,サイズの大きなファイルを検索
find . -type f -exec ls -s {} \; | sort -n -r | head -5


10,サイズの小さなファイルを検索
find . -not -empty -type f -exec ls -s {} \; | sort -n | head -5


11,ファイルの種別で検索
find . -type d


12,指定したファイルよりあとに更新されたファイルを検索
find -newer ordinary_file


13,ファイルサイズで検索
find ~ -size +100M


14,よく使うfindコマンドを登録
alias rmc="find . -iname core -exec rm {} \;"


15,大きなファイルを削除
alias rm100m="find / -type f -name *.tar -size +100M -exec rm -i {} \;"


16,再帰的にあるファイルを一気に削除する
find . -name "*.html" -print (一応確認)
find . -name "*.html" -exec rm -f \{\} \;


findを極める!