Home > OS >  Filter followed tail to file using grep and redirect
Filter followed tail to file using grep and redirect

Time:10-01

I want to get the output of

tail -f /var/log/apache2/error.log | grep "trace1"

into a file. But

tail -f /var/log/apache2/error.log | grep "trace1" > output.txt

does not work, while the first command gives an output in my terminal window as expected.

I guess it has to do with the follow-parameter, because if I omit the "-f", the output file is created.

But why is this so and how can I achieve my goal?

Regards, Axel

CodePudding user response:

Can you please try:

tail -f /var/log/apache2/error.log | grep "trace1" | tee -a output.txt
  • Related