saeki’s blog

The limits of my code mean the limits of my world.

ファイルの内容をgrepして行を絞り込む

Apacheのログを調べる必要があったのでメモ。
賢い人はFluentdやElasticsearchやKibanaを使ってます。使いたい。

$ grep -i <検索文字> <ファイル名> | cat
$ grep -i "get /***" /var/log/httpd/access_log | cat

-iオプションがあると大文字小文字を区別しない。

catする前に絞り込んだ行数を確認すると良いかも。

$ grep -i <検索文字> <ファイル名> | wc -l
$ grep -i "get /***" /var/log/httpd/access_log | wc -l
10