1

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 1

0

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.

  1. 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.

  2. 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.

2
  • thanks a lot for replying but what if i want to see the first line during run ?
    – user
    Jul 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 like my_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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .