▼すべてを開く。
▲すべてを閉じる。
$ grep -F '^I' boot.log Apr 6 13:44:59 localhost firstboot: ^IBefore reporting any problems, please make sure you are using the most Apr 6 13:44:59 localhost firstboot: ^Irecent XFree86 packages available from Red Hat by checking for updates Apr 6 13:44:59 localhost firstboot: ^Iat http://rhn.redhat.com/errata or by using the Red Hat Network up2date Apr 6 13:44:59 localhost firstboot: ^Itool. If you still encounter problems, please file bug reports in the Apr 6 13:44:59 localhost firstboot: ^IXFree86.org bugzilla at http://bugs.xfree86.org and/or Red Hat Apr 6 13:44:59 localhost firstboot: ^Ibugzilla at http://bugzilla.redhat.com
grepコマンドで、-Fオプションに検索する文字列「'^I'」、検索対象のファイル「boot.log」を指定すると、文字列「^I」を検索して表示する。検索する文字列は、引用符「'」で囲むこと。
grepコマンドのオプション | |
-F | 固定文字列として検索する |
grepコマンドは、デフォルトで検索パターンを正規表現として解釈する。正規表現ではキャレット「^」は行頭を表すため、'^I'は行頭がIで始まる文字列を検索してしまう。これらの正規表現で特別な意味を持つ「^$?*.[]」などのメタキャラクタを単なる文字として検索するには-Fオプションを指定する。以下のコマンドでは目的の文字列は検索できない。
$ grep '^I' boot.log