一般的な検索コマンド
名前でファイルを検索する
find . -name data.txt
現在のディレクトリで100MBを超えるファイルを検索します:
find . -xdev -type f -size +100M
ディレクトリ内の特定のファイルを検索する
find ./data -name tests*
拡張子でファイルを検索:
find . -name *.jpg
特定の名前のファイルまたはディレクトリを検索します:
# find only files, we need to use the -f option:
find ./ -type f -name "results*"
# To find only directories, we need to use the -d option:
find ./ -type d -name "results*"
複数のディレクトリでファイルを検索
find ./src ./res -name app*.* -type f
特定のテキストを含むファイルを検索する
find ./src -type f -exec grep -l -i "getall" {} ;
サイズでファイルを検索
さまざまなサイズのファイルを検索することもできます。サイズオプションは次のとおりです。
- cバイト
- kキロバイト
- Mメガバイト
- Gギガバイト
find / -size 10M
特定のファイルを見つけて削除する
find . -type f -name "temp*" -exec rm {} ;