Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Suppose I have a Terminal open that contains thousands of lines of output from my previous commands over the past few hours/days. How do I search that recorded output for a string? I'm especially interested in a solution that doesn't require the mouse.

I know I should have used tee, but that's not always convenient.

I know I could "Select All", then open an editor, paste, then search, but I'm hoping for something simpler (and Select All seems to require the mouse).

I was hoping there would be a "Find..." command in the menu bar (like Mac OS X has).

share|improve this question

migrated from stackoverflow.com Jun 30 '11 at 1:07

3 Answers

up vote 5 down vote accepted

Finding text in scrollback is a weakness of most terminal emulators; the only ones I know of that provide it are OS X Terminal and Terminator. That said, you could run GNU screen in any terminal and search its scrollback buffer in copy mode.

share|improve this answer
Thanks geekosaur. I also just found this 'idea' on the ubuntu site, which just seems to confirm that it is impossible as of yet: brainstorm.ubuntu.com/idea/9841 – Joseph Johnson Jun 28 '11 at 4:56

If you are running a gnome-terminal (default GUI terminal on ubuntu) you can hit shift+ctrl+f, type your search terms, and hit enter. Still graphical, but no mouse required.

share|improve this answer
Thanks SynapticUnderrun, but your tip doesn't seem to work for me. I'm using a fresh install of ubuntu 10.4. – Joseph Johnson Jun 28 '11 at 20:59
1  
This works on ubuntu 10.10 and 11.04. I'm running 10.10 right now and using gnome-terminal 2.32.0 so perhaps upgrading gnome-terminal would help. Since this uses a gtk pop-up window to enter in search text, you will have to be running X for it to work. But you don't need to use the mouse and it will search the entire terminal buffer (which you can set to unlimited in the Edit->Profile Preferences dialog). – SynapticUnderrun Jun 29 '11 at 16:31
Thanks SynapticUnderrun, I'll definitely look for that next time I can upgrade. – Joseph Johnson Jun 29 '11 at 20:38

Have you considered using pipe and grep?

YourCommand | grep str

Hope this helps

share|improve this answer
He asked for searching in output of already run commands and also mentioned that tee is not always convenient to use and so is grep! – Aamir Jun 29 '11 at 1:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.