How to copy all current output in Terminal to a file when too large for clipboard after it has already been outputted?
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.
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
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 about 8 years
-
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 about 8 yearsAh, 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 about 8 years@RPiAwesomeness: Ok, I have done so.
-
muru about 8 yearsIf it's out of scroll, then the data is lost. How do you know it's too much for the clipboard?
-
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 about 8 yearsIs the final line the same every time?
-
goo about 8 yearsApply 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 about 8 yearsuse screen -L, so anything you do in your shell is logged. You may extract the desired output from the logfile
-
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 about 8 yearsWell, 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 about 8 yearsFrom 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 about 8 yearsLook, 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 about 8 yearsAnd it is also clearly said in my clarification section.
-
egmont about 8 yearsCould 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 about 8 yearsWhen 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 about 8 yearsYes, 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 about 8 yearsI can't be sure, but either way the copy and paste method is not working so I need another!
-
Admin almost 6 yearsPerhaps just give that as an answer then.
-
Marcelo Teixeira Ruggeri about 4 yearsIt's 100k lines and a lot of chars to gedit handle alone