Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

This question came from our site for professional and enthusiast programmers.

1  
I didn't even realize there was a "Find..." command until you mentioned it in OS X, so +1 to this question for being the answer to my Googling. – ArtOfWarfare Oct 2 '13 at 17:48
up vote 10 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
    
Just adding that you can use Byobu which based on TMux or Screen – Boynux Nov 27 '13 at 2:12
    
Terminator doesn't highlight text when you search for it. – user171453 Mar 16 at 10:30

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
    
Just worked for me also in xfce4-terminal, (X)ubuntu Raring 13.04. Thanks. – Gringo Suave Oct 26 '13 at 2:25
1  
This should be the accepted answer. Works for me on Ubuntu 14.04 LTS. – user171453 Mar 16 at 10:34

Have you considered using pipe and grep?

YourCommand | grep str

Hope this helps

share|improve this answer
2  
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

Try konsole in kde. It works with gnome/unity too. Program the Find shortcut to alt-f or ctrl-f, it can search forward or backward, plus it will highlight new output that matched the searching pattern.

share|improve this answer

You must log in to answer this question.

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