How to copy all current output in Terminal to a file when too large for clipboard after it has already been outputted?

13,007

Pasting large data into terminals is often troublesome (I don't quite know why), so I recommend to perform Edit -> Select All, followed by Edit -> Copy in gnome-terminal, and then Paste into some non-terminal application such as gedit.

I tried with 600k lines. It took a couple of seconds to Select All and Copy in gnome-terminal, followed by a minute or so to Paste it into gedit, but luckily it worked flawlessly (on Ubuntu 16.04 beta; 15.10 is unlikely to behave differently).

But if nothing gets copied to the clipboard then you just need to copy in smaller chunks as the limit will have been reached.

Share:
13,007

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I have a slight problem at the moment, I have a large amount of output in a Terminal (gnome-terminal) at the moment, so large in fact that the clipboard won't take it... So I wondering if there is any way for me to get a script to run through all the current output there or something and then put it into a file, line by line if it has to? I am running Ubuntu GNOME 15.10 with GNOME 3.18.

    Clarification: As this seems to be confusing a few, I do not want to be told how to pipe the output or similar to a file before it's outputted it into Terminal, I currently have over 100k lines in my Terminal and I wish to move them into a file but the clipboard won't take them and rerunning the command which outputted them and then piping into a file isn't really an option at the moment...

    • RPiAwesomeness
      RPiAwesomeness about 8 years
    • Admin
      Admin about 8 years
      @RPiAwesomeness: No, this is not a duplicate of that because I do not want to know how to do it before hand, I want to know how to do it after I've got the output in Terminal...
    • RPiAwesomeness
      RPiAwesomeness about 8 years
      Ah, I see. You might want to include that in the title to make it more clear. Perhaps something like "How to copy all current output in Terminal to file when too large for clipboard after output is stopped" or something similar?
    • Admin
      Admin about 8 years
      @RPiAwesomeness: Ok, I have done so.
    • muru
      muru about 8 years
      If it's out of scroll, then the data is lost. How do you know it's too much for the clipboard?
    • Admin
      Admin about 8 years
      @muru: It's not out of scroll. I know it's to much for the clipboard because every time I copy and paste it somewhere the final line is not the same as that in the Terminal output.
    • muru
      muru about 8 years
      Is the final line the same every time?
    • goo
      goo about 8 years
      Apply the {Select, Copy, Paste} thing to subsets of the output. First line through Nth line, N+1th line to 2Nth line, lather, rinse, repeat.
    • cmks
      cmks about 8 years
      use screen -L, so anything you do in your shell is logged. You may extract the desired output from the logfile
    • egmont
      egmont about 8 years
      @waltinator's response could probably be made more convenient this way (no need to manually copy-paste with the mouse): Select, Copy, Paste the entire contents, and let's say that only the first 10.000 lines were copied. Go to Profile Prefs and change the scrollback size to be smaller by 10.000 lines (so that you lose what you've already saved) and repeat these steps. (You might want to create and switch to a temporary profile first so that this action doesn't influence other g-t tabs/windows that are also open.)
  • Admin
    Admin about 8 years
    Well, for me copying the data to the clipboard failed because only part of the data got there. I know this because when I then pasted it into gedit only a small part of it was there.
  • egmont
    egmont about 8 years
    From your description, you can't be sure whether the copy or the paste phase failed. I'm sorry that I can't give you any more help; all I know is that it worked for me.
  • Admin
    Admin about 8 years
    Look, the title says "How to copy all current output in Terminal to a file when too large for clipboard after it has already been outputted?", how does that not cover it?
  • Admin
    Admin about 8 years
    And it is also clearly said in my clarification section.
  • egmont
    egmont about 8 years
    Could you please clarify what does it mean that "the clipboard won't take" the contents? Do you get an error message or something like that? Can you examine the contents of the clipboard without pasting it? If so, how? Or do you paste it somewhere and notice that after the paste you get corrupted data? If so, how can you be sure that it's the copy and not the paste phase that corrupts it?
  • Admin
    Admin about 8 years
    When I select all the data and copy it, when I then go somewhere and paste it only a small amount of the data (in comparison to the actual amount) is pasted.
  • egmont
    egmont about 8 years
    Yes, I understand it. You perform two steps in a row. First copy it, then paste it. The end result is not what you expect. Yet, you're certain that it's the first step (copy) that's not executed correctly. I'm asking: How can you be sure that it's not the second step (paste) that truncates your data? Is my question clear?
  • Admin
    Admin about 8 years
    I can't be sure, but either way the copy and paste method is not working so I need another!
  • Admin
    Admin almost 6 years
    Perhaps just give that as an answer then.
  • Marcelo Teixeira Ruggeri
    Marcelo Teixeira Ruggeri about 4 years
    It's 100k lines and a lot of chars to gedit handle alone