2013/07/11

linux grep

grep 検索内容 file
=>その行の内容を表示する

-i 大文字と小文字を区別しない
-l ファイル名だけを出力する
-n 行番号を表示する
-v 一致しない行を表示する
--color 一致文字列に色を付ける事ができる
-o 合致する文字だけ

・OR 検索する
grep -e "localhost"  -e "dnc" 21show_master_status.log
grep "aomori\|yamanashi" fruits.txt

・AND
grep "localhost" 21show_master_status.log | grep "dnc"