Skip to main content

Output redirection is not working with top piped to grep [Resolved]

When I run this command in Linux:

$ top -b -d 20 | grep "load average" -A 20 > top.log

top.log is always empty.

But when I run this command:

$ top -b -d 20 | grep "load average" -A 20 | tee top.log

then top.log has contents.

If I don't want to use tee (because I don't want the output to be displayed onto the console), how do I correct the first command so that top.log is updated?

My machine uses CentOS Linux 7 (Core).


Question Credit: kurt
Question Reference
Asked March 29, 2019
Posted Under: Unix Linux
23 views
Your Answer
D:\Adnan\Candoerz\CandoProject\vQA