views:

29

answers:

2

Hi I have lots of logfiles with ^[[1m (as vim displays it) in them. I want to watch a logfile life via

tail -n 1000 -f logfile.log | grep <expression-for-escape-sequence>

and only get lines that have bold in them. I am not sure which grep options I should use and have tried the following already:

tail -n 1000 -f logfile.log | grep "\033\0133\061\0155"
tail -n 1000 -f logfile.log | grep "\033\01331m"
tail -n 1000 -f logfile.log | grep "\033\[1m"

It does not work though... And yes there are bold lines in the last 1000 lines of logfile.log, testing with

echo -e "\033\01331mTest\033\01330m" | grep ...

same results... ;)

Appreciate any help!

+2  A: 
John Kugelman
Thanks! this is exactly what I was looking for! It was really a nightmare searching google for a solution because of all the special characters ;) !
Anon
A: 

This works (in a POSIX shell, not necessarily bash):

echo -e "\033\01331mTest\033\01330m" | grep "$(printf "\x1b\\[1m")"
jpalecek