ablog

不器用で落着きのない技術者のメモ

grep でハイフン"-"を含む文字列を検索する

$ grep -c '- java.sql.SQLException' *
grep: invalid option --
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.

と怒られるので、"\"でエスケープしたら成功した。

$ grep -c '\- java.sql.SQLException' *
default.log:0
default.log.2009-02-01:0
default.log.2009-02-02:4
default.log.2009-02-03:7