複数の文字列を含むファイルの検索

複数の文字列を含むファイルの検索

一般的なマルウェアを含むスクリプトを見つけようとしていますが、各ファイルで複数の文字列を一致させる必要があります。私が使っているのはうまくいきますが、なぜ出力に次のものが表示されるのかわかりません。

# egrep -rli --include='*.php' 'return base64_decode' . | xargs -0 grep -l 'isset'
grep: ./wp-content/themes/twentyfourteen/js/menu61.php
./wp-content/themes/twentyfourteen/themes.php
./wp-content/themes/twentytwelve/file68.php
./wp-content/themes/twentythirteen/inc/page.php
./wp-content/themes/twentythirteen/inc/template.php
./wp-content/upgrade/include.php
./wp-content/plugins/wp-slimstat/browscap/diff8.php
./wp-content/plugins/quick-contact-form/gallery56.php
./wp-content/plugins/addthis/css/include.php
./wp-content/plugins/addthis/includes/include.php
./wp-content/plugins/tpc-memory-usage/images/code77.php
./wp-content/plugins/gotmls/images/index.php
./wp-content/plugins/tinymce-advanced/langs/object56.php
./wp-content/plugins/wp-security-audit-log/dirs70.php
./wp-content/plugins/wp-security-audit-log/css/list76.php
./wp-content/plugins/wp-security-audit-log/proxy.php
./wp-content/plugins/image-widget/lang/alias.php
./wp-content/plugins/my-page-order/template.php
./wp-content/uploads/2015/01/footer87.php
./wp-content/menu.php
./wp-includes/js/thickbox/db.php
./wp-includes/js/jquery/ui/footer39.php
./wp-includes/js/imgareaselect/general.php
./wp-includes/css/page25.php
./wp-includes/Text/Diff/Engine/dump.php
: No such file or directory

出力は良好で、私が望むものですが、行1に表示される理由は次のとおりです。

grep: ./wp-content/themes/twentyfourteen/js/menu61.php

最後の行には常に次のものが表示されます。

: No such file or directory

最後に、ファイルにパイプすることは機能しません。

# egrep -rli --include='*.php' 'return base64_decode' . | xargs -0 grep -l 'isset' >> asd

ベストアンサー1

xargs引数なしで実行してみてください-0。これらのパラメータはxargsnullで区切られた引数を期待するように指示しますが、ここではそうではありません。

おすすめ記事