7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

検索候補リストから連続grepを1行で書く

Posted at

コマンドラインで検索するリストを作って、連続でgrepを1行で書く。(環境 MacOS)
grepとxargsを連携する。

事前準備として、検索候補リストをfileに書き出しておく。

$ cat list
aaa
bbb
ccc

そして、検索対象は、search_dirとすると、

$ cat list | xargs -I 'key' grep -r 'key' ./search_dir

これで検索候補リストを一行ずつ search_dirからgrepできる。

awkとかとも連携

$ awk -F '"' '{ print $4 }' | xargs -I 'key' grep -r 'key' ./search_dir
7
6
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
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?