[[Linux全般]]

~
*パターン1 [#xa6582f4]
もっとも簡単なgrepを使用したコマンド。ディレクトリをスキップする。
 # grep 文字列 * -d skip

*パターン2 [#x1aa80ea]
 # find /etc -type f -print | xargs grep 文字列

*パターン3 [#y91edde3]
findとgrepの組み合わせで特定の文字列を含むファイルを検索できます。
 # find /var/www/ -name .htaccess |xargs grep 'memory'
 /var/www/html/.htaccess:php_value memory_limit 256M
 /var/www/html/admin/.htaccess:php_value memory_limit 1024M
 /var/www/html01/.htaccess:#php_value memory_limit 64M
 /var/www/html01/.htaccess:php_value memory_limit 256M

対象のファイル名条件を複数にするには -o(-orでも可)のオプションをつけてあげれば、設定できる。
 # find . \( -name '*.php' -o -name '*.html' \) | xargs grep 'hoge'


~
~

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS