I have problem with terminal
.. I run a command but it took a time to be finish and it printed a lot of lines in terminal but when I came back to first line by mouse I got blank and empty screen .. How can I make terminal
save the lines exist ?
1 Answer
There might be some bugs with your terminal emulator (gnome-terminal
I assume), but if your goal is to read that data, you don't need to rely on terminal's scroll. You could always try a different terminal emulator, but all you need is to do something with that text.
We can redirect that stream of data to a file (
&>
instead of>
will capture even error output):my_command_with_long_output > /path/to/file
Then read it with some text editor of choice.
You can also redirect it directly to a pager like
less
:my_command_with_long_output | less
and use
less
's scrolling (j/k, Ctrl+d/u).
The point is that the terminal emulator doesn't even need to be able to scroll for you to see long output.
-
thanks a lot for replying but what if i want to see the first line during run ?– userJul 13, 2021 at 12:25
-
There are so many options how to answer this, but I would suggest trying
tee
command. You would use it likemy_command | tee /path/to/file
and it basically redirects output to said file as well as outputs it to stdout for you to read instantly. You could combine it with more tools, Maybe you wanted to store it as whole for you to read with editor, but only see first line during run:my_command | tee /path/to/file | head -n 1
. Jul 14, 2021 at 7:25