When performing a grep
like:
$ tail -f apilog_2014.07.09.log | grep "HELLO" | grep "99999"
I get the desired output:
12:22:35 server apache2: HELLO FRIEND 99999
12:22:35 server apache2: HELLO FRIEND 99999
12:22:35 server apache2: HELLO FRIEND 99999
However if I do:
$ tail -f apilog_2014.07.09.log | grep "HELLO FRIEND" | grep "99999"
I don't get anything.
My locale settings are all set to en_US.utf8
and I've tested with [[:space:]]
and with \s
. No results. The file itself is text/plain; charset=us-ascii
(checked with file -bi apilog_2014.07.09.log
).
The files themselves are written with rsyslog
, if that is any type of hint. Using Ubuntu 12.04.4 LTS
.
Is there anything I'm missing?
As requested:
$ grep "HELLO" apilog_2014.07.09.log | od -c
0000000 1 4 : 2 7 : 0 0 s o f i a c
0000020 a r l o s : A P I L O G H
0000040 E L L O F R I E N D t e s t
0000060 i n g \n 1 4 : 3 1 : 4 5 s o f
0000100 i a c a r l o s : A P I L
0000120 O G H E L L O F R I E N D
0000140 t e s t i n g 6 3 9 0 3 \n
0000156
UPDATE 14 Jul 2014
Answer here: Grep with spaces suddenly doesn't work
Related question (same solution): Piping from grep to awk not working
HELLO
andFRIEND
. Please rungrep HELLO apilog_2014.07.09.log | od -c
and post the output here. – terdon Jul 09 '14 at 10:56https://gist.github.com/charlydagos/de3470c65dd99d04cbc0
– Carlos D Jul 09 '14 at 12:39grep -e 'HELLO.*FRIEND' tst.txt
. – slm Jul 09 '14 at 12:41grep
aliased togrep --color=always
. That's not a very good idea, you might want to change that togrep --color=auto
(see here). Anyway, could you please post the output of\grep HELLO apilog_2014.07.09.log | od -c
instead? That way the color codes of the matched portion won't confuse things (the\
will bypass any aliases and run the command directly). – terdon Jul 09 '14 at 13:00grep -E "HELLO[^\S+]FRIEND" file
– user13107 Jul 09 '14 at 13:06--color=always
(changed that now to--color=auto
), I tried with withauto
again.Hopefully it yields some help :) https://gist.github.com/charlydagos/ae38cbe30577225188c5
Thanks guys.
– Carlos D Jul 09 '14 at 13:58