I have a command that outputs thousands of lines. I actually need these lines in order to see the progress of the command. But I do not need to see more than the 10 most recent lines.
How can I do that?
I already tried using a pipe
and tail
. But it did not work. I just got the last ten lines after the original command finished:
whatever command that has too much output | tail -f
It is important that the console does not get cleared or something like this because there is some important infomation that gets printed right before the command with the lengthy output.
An example:
echo "Very important information. MUST BE VISIBLE!"
# This gives me about 10,000 lines of output pretty fast!
# This output should be shrinked down to the most recent 10
tar -cvf "Bckup.tar" "folder to backup/"
# More code
I hope this clears it up.
EDIT:
The problem with multitail
is that it takes up the entire screen. So if I had more than just one output (which I have. Multiple commands with important information are run before this. And I need to use it multiple times).
Something like running this in screen with just 10 lines to display would be perfect. (I know that does not work).
You could imagine that like there is some output from other commands. Then I call the command with the lengthy output. This output stays in a screen that only can display something like 10 lines. After the command is finished more output goes to the console and this should be right beneth it like normal output.
Output
Important Information
Other commands output
----------------------------------------
some lines for the tar command
----------------------------------------
More output
....
....
(Just without the lines)
echo
or a more complicated command? – Joseph R. Aug 25 '13 at 23:12whatever command that has too much output | tee file-with-thousands-of-lines | tail
thenless file-with-thousands-of-lines
– Skaperen May 05 '15 at 10:01screen
. None of the suggested answers actually addressed the question. – Thomas Dickey Oct 01 '16 at 01:34