I want to exclude some erros from log. I'm using a Raspberry 3b+.
I use
main.py >> log.txt 2>&1 | grep -v "Network is unreachable"
My error that I don't want is
[tcp @ 0x19ccea0] Connection to tcp://192.168.1.32:554?timeout=0 failed: Network is unreachable
I can put the whole error in grep because the ip adress may change
However this error is still in my log.txt file when I run my main.py
You need to pipe to grep
, and then redirect grep's output to the file. You're redirecting all the output to the file, so nothing goes to grep
.
main.py 2>&1 | grep -v "Network is unreachable" >> log.txt