Filter out output and then write to a file

I have a process which writes lots of output to the screen and am capturing it to a file.

But the issue is that there are few lines which repeat every second which is causing the file size to be enormous. I am trying to filter out and then run the command but its not working.

Can you confirm if the below command is correct?

<process> | grep -v "java vm started" | tee 2>$1 ~/abc.log
<process> | grep -v "java vm started" | tee 2>&1 ~/abc.log
1 Like

Sorry about the typo.

Yes, I used the above command but it did not work. As a matter of fact, the "process" runs all the time and writes output every second and the log file increases every second consequently.
Since, its not working wanted other option?

are you sure you are searching for the correct string?...
can you paste the sample output of the process?...

--ahamed

Ok, below are few lines which repeat:

Calling java class for read.
Java read returned no data currently available.
Calling java class for read.
Java read returned no data currently available.
Calling java class for read.
Java read returned no data currently available.

But the search string is different... it is not matching right?

<process> | egrep -v "(Java read|java class)" | tee 2>&1 ~/abc.log

--ahamed

1 Like

Yes, the search string was different.

There were like 3 or 4 lines which repeat and I did not want to paste all the four search strings as it is similar to one of them.

Now then, I am using the same piece of code you mentioned and even then its not working. It is creating the file but is a zero byte file. Something else needs to be written to the log but command just not doing anything.

With this code are you getting the desired output on the screen?

<process> | egrep -v "(Java read|java class)"

--ahamed