Terminal: How to select many lines? by finding regular expression? found another solution!

I would like to select many thousands of lines of output and copy it into Gedit, for example. This takes too long to select with the mouse. I saw that I can use the Terminal’s Find function and I’ve come up with several regular expressions that are successfully finding and selecting the entire line where I entered a command (e.g.: user@host(.|\n)*), but this is only selecting that one line.

Isn’t there regex that would basically match all of the text between two prompts, between two “user@host”'s? I tried a bunch of expressions I found out there that supposedly span multiple lines but maybe the Terminal doesn’t allow this sort of selection?

I’m not sure what other options there are. I can’t run the command again and have left Terminal open until I can grab the text. It is a lot. I don’t have a buffer limit set. I tried using the mouse of course but after like 5 minutes my finger started to hurt from holding the button down so long! I copied the text I had selected and pasted that into Gedit, then tried again for another few minutes…

I did this a few times, I have over 50,000 lines in Gedit now, and the scroll bar in Terminal is only about 10% of the way up! I’m glad I stopped because the rest of the text I want to copy goes back to nearly the beginning of Terminal’s buffer! It’s maybe 500,000 lines and would take 50 minutes of constantly holding the mouse button down at this rate…

The Terminal’s “Select All” Ctrl+Shift+A unfortunately only seems to select the bottom most visible part of the terminal.

Oh hell yeah I just now found a way: by selecting some text at the beginning of the output and then moving the scroll bar to the bottom, holding Shift and selecting the end, it selected it all! It took like a minute to paste into Gedit and I was close! 489,586 lines!

Still it might be nice to know of a way to do it with regular expressions too if you might know!

1 Like

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.