I need to monitor a log file which sometimes contains invalid UTF8 characters.
Like this:
shaozr@fedora utf8-cut (bear_from_3.1.18) $ tail -F a.txt
a我々はMozartが好きです。
a我々はBachも好きです。
a▒▒▒々はMozartが好きです。
a▒b々はMozartが好きです。
a我々はMoz▒rtが好きです。
a我々はMozartが好きです。
I can filter the content by 'pipe to grep' once :
shaozr@fedora utf8-cut (bear_from_3.1.18) $ tail -F a.txt | grep -a Mozart
a我々はMozartが好きです。
a▒▒▒々はMozartが好きです。
a▒b々はMozartが好きです。
a我々はMozartが好きです。
a▒▒▒々はMozartが好きです。
a▒b々はMozartが好きです。
But I try to filter the content by 'pipe to grep' more than once, I just get nothing.
shaozr@fedora utf8-cut (bear_from_3.1.18) $ tail -F a.txt | grep -a Mozart | grep -a Mozart
^C
shaozr@fedora utf8-cut (bear_from_3.1.18) $ tail -F a.txt | grep -a -v Bach | grep -a Mozart
^C
shaozr@fedora utf8-cut (bear_from_3.1.18) $
I have tried on grep v3.7 and v3.1, results are same.
And if I subsitue 'tail -F' with just 'cat', above 'multi layer grep pips' works.
shaozr@fedora utf8-cut (bear_from_3.1.18) $ cat a.txt | grep -a -v Bach | grep -a Mozart
a我々はMozartが好きです。
a▒▒▒々はMozartが好きです。
a▒b々はMozartが好きです。
a我々はMozartが好きです。
a▒▒▒々はMozartが好きです。
a▒b々はMozartが好きです。
a我々はMozartが好きです。
a▒▒▒々はMozartが好きです。
a▒b々はMozartが好きです。
What should I do to monitor&filter text containing invalid utf8 char by 'pipe to grep' more than once?
Thanks in advance.
-F
intail -F a.txt
? – muru Nov 04 '22 at 02:38