ファイル内の文字列に対して複数のディレクトリを検索する

ファイル内の文字列に対して複数のディレクトリを検索する

ファイル内の文字列に対して複数のディレクトリを検索するコマンドを使用するのに役立つ人はいますか?httpd.conf複数のhttpdインスタンスからVIPを検索しています。

私は以下を使用しています:

find ./ -name "httpd.conf" | xargs grep 10.22.0.141 cut -d: -f3- | cut -d ' ' -f4 | sort | uniq -c 

しかし、うまくいきません。

charl@rom11-TEST $ ls -latr
total 124
...
drwxrwxr-x 7 root root 4096 Mar 9 13:41 bofac-Wrapper
drwxr-xr-x 7 root root 4096 Jul 29 2014 bofac-admin
drwxrwxr-x 7 root root 4096 Jul 29 2014 bofac-chas-test
drwxrwxr-x 7 root root 4096 Jul 29 2014 bofac-chasdps-test
drwxrwxr-x 7 root root 4096 Oct 10 14:09 bofac-vpn-chas-test
...

デフォルトではhttpd、インスタンスは強調表示されますが、理想的にはディレクトリ全体に対してコマンドを実行します。

ベストアンサー1

grep -r --include "httpd.conf" "10.22.0.141" . | cut -d: -f3- |\
cut -d ' ' -f4 | sort | uniq -c

おすすめ記事