Skip to content

Instantly share code, notes, and snippets.

@donchan922
Last active August 20, 2020 22:26
Show Gist options
  • Save donchan922/ee2393dc8579353ebbe50cc0d5f10498 to your computer and use it in GitHub Desktop.
Save donchan922/ee2393dc8579353ebbe50cc0d5f10498 to your computer and use it in GitHub Desktop.
$ find 検索対象のディレクトリ -name 検索対象のファイル -type f -print0 | xargs -0 grep 検索したい文字列
# 例1. カレントディレクトリ配下の「foo*」ファイル内に「hoge」が含まれているものを検索する
$ find . -name 'foo*' -type f -print0 | xargs -0 grep hoge
# 例2. カレントディレクトリ配下の「.txt」ファイル内に「hoge」が含まれているものを検索する
$ find . -name '*.txt' -print0 | xargs -0 grep hoge
# 例3. /var/log配下のファイル内に「hoge」が含まれているものを検索する
$ find /var/log -type f -print0 | xargs -0 grep hoge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment