0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ファイル検索するコマンド一覧

Posted at

概要

ファイル検索する際に、少し複雑で覚えていないけどよく使うコマンド一覧。

ファイル名に特定の文字列を含むファイルリスト

通常

/path/to/dirにある、wordという文字列をファイル名に含むファイルリスト

find [検索対象ディレクトリパス] -type f -name "*word*"

特定ディレクトリ除外

/path/to/dirにある、wordという文字列をファイル名に含むファイルリストで/path/to/dir/backup/path/to/dir/errorを除外する場合

find /path/to/dir -type f -name "*word*" | grep -E -v "^/path/to/dir/(backup|error)/"

特定の文字列をファイル内に含むファイルリスト

通常

/path/to/dirにある、wordという文字列をファイル内に含むファイルリスト

grep [検索したい文字列] -rl [検索対象フォルダのパス]

特定ディレクトリ除外

/path/to/dirにある、wordという文字列をファイル内に含むファイルリストで/path/to/dir/backupと`vendorとnode_modulesを除外する場合

grep 'word' -rl /path/to/dir --exclude-dir={vendor,node_modules}

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?