#-----------------------------
# <文字列>抽出
cat /var/log/messages | grep "<文字列>"
#-----------------------------
# リアルタイムで指定した<文字列>を確認する
tail -f /var/log/messages | grep --line-buffered "<文字列>"
#*****************************
# <文字列1>,<文字列2>を色付けて tail -f 出力する
tail -f /var/log/messages | grep --color=auto -E "<文字列1>|<文字列2>|$"
#*****************************
#【例】tail -f メッセージのタイムスタンプ部分を色付き出力する
tail -f /var/log/messages | grep --color=always -E '^[A-Z][a-z]{2} [ 0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}|$'
#*****************************
#【例】tail -100 先頭~ ]: 迄の文字を色付け出力する
tail -100 /var/log/messages | grep --color=auto -E "^.+]:|$"
PR