I want to write the output of a specific \'top\' command to a file. I did some googling and find out that it can be done by using the following command.
top
As pointed out by @Thor in a comment, you just need to ensure that grep
is not buffering arbitrarily but per-line with the --line-buffered
option:
top -bn 10 | grep 'init' --line-buffered | tee top-output.txt
Without grep-ing, redirecting the output of top
to a file works just fine, interrupt included.