GNU/Linux >> Linux の 問題 >  >> Linux

Linuxのfindコマンドの使用–例を使用した使用法

一般的な検索コマンド

名前でファイルを検索する

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 {} ;

Linux
  1. findコマンドを使用してLinux上のファイルとディレクトリを検索します

  2. 25Linuxでの便利なfindコマンドの実用例

  3. Linux Sedコマンド:使用法と例

  1. 検索コマンドを使用してLinuxでファイルを検索する方法

  2. Linuxでの解凍コマンドの実用例

  3. Linux で find コマンドを使用して、スペースのあるファイルを検索して削除する

  1. 例を含むLinuxzforceコマンドチュートリアル

  2. Linuxでの日付コマンドと使用例

  3. Linuxの実用的な例を含むコマンドの検索