-1
I have this line that appears every minute in my log file:
2016-03-29 21:52:46,226 INFO 200 GET /api/ping (0.0.0.0) 0.34ms
I want to tail
this log file without showing these lines.
I tried:
tail -f log.txt | grep -v "ping"
-1
I have this line that appears every minute in my log file:
2016-03-29 21:52:46,226 INFO 200 GET /api/ping (0.0.0.0) 0.34ms
I want to tail
this log file without showing these lines.
I tried:
tail -f log.txt | grep -v "ping"
0
You could do something like this:
tail -F ~/Your.log | while read LINE;do
if [[ ! "$LINE" =~ "ping" ]]; then
echo $LINE
done
fi
done
Do you mean that what you tried don't work? – Sébastien VALSEMEY – 2016-03-30T15:17:33.263
1The solution has been written a couple of times in the context of other shell commands. You should look for "stdbuf" in the upper right corner of this web page. – Gombai Sándor – 2016-03-30T15:18:48.510
What is the problem? Just tried this on my machine and it works as expected.
echo "..GET /api/ping (0.." | grep -v "ping"
yelids a 1 result with no matches. – Matt Clark – 2016-03-30T15:29:39.937@MattClark echo sthing is easy because its output is finished and flushed. A continuous pipe means buffering which is usually a friend but when waiting for the buffer to fill and flush means an impact on the process, it's an ugly enemy. Luckily, it can be tamed with stdbuf among a couple of options. – Gombai Sándor – 2016-03-30T19:25:45.300
even still,
tail -n 0 -f test | grep -v "ping"
and run this in another terminalecho "..GET /api/ping (0.." >> test
still result in no output. I've tested this on 4 different unix distros, and cygwin on windows. All have the same expected behavior. – Matt Clark – 2016-03-30T20:40:48.603