Sunday, July 10, 2022

[SOLVED] How to redirect all lines not containing specific text to a text file?

Issue

Getting a flood of 'Dropping' error messages from the kernel that can fill the HD quickly. I'd like to filter them out before they reach the log file. What is wrong with this syntax?

myprogram >(grep -v Dropping) > myprogram.log 2>&1 &

It seems to stop the output. Also tried various things using 'grep |' without success.


Solution

It's not clear if "myprogram" use STDIN or STDERR to print "Dropping", anyway, you can use:

myprogram 2>&1 | grep -v Dropping > myprogram.log


Answered By - Ronaldo Ferreira de Lima
Answer Checked By - Mildred Charles (WPSolving Admin)