How grep with -e (regex) `/log/messages` ? [ solved ]

Hi,

I would like to display the new lines of /var/log/messages that contain either IN_MyText or OUT_MyText (no matter where in the line)

I've tried

tail -fn 3 /var/log/messages | grep --color --line-buffered -e "(IN|OUT)_MyText"

But the output stay blank, when it should not...

Any ideas ?

20 points · 3 comments · view on lemmy.world

3 Comments

CosmicGiraffe@lemmy.world · 4 pts · 1y

It's marked solved, but since OP didn't post the solution:

-e uses basic regular expressions, where you need to escape the meta-characters ((|)) with a backslash. Alternatively, use extended regex with -E

$ echo a | grep -E "(a|b)"
a
$ echo a | grep -e "\(a\|b\)"
a
$ echo a | grep -e "(a|b)"
$ echo a | grep -E "\(a\|b\)"
vk6flab@lemmy.radio · 2 pts · 1y (1 reply)

Do you get output if you use that exact tail command without the grep pipe?

Gordon_F@lemmy.ml · 1 pts · 1y

Yes