32

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).

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

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

  • 2
    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
16

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.

  • 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 '16 at 10:30
46

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.

  • 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
  • 4
    This should be the accepted answer. Works for me on Ubuntu 14.04 LTS. – user171453 Mar 16 '16 at 10:34
7

Shortcut to find string inside the terminal data : ctrl + shift + f

  • 1
    Works with default xfce4-terminal 0.6.3 on Xubuntu 16.04. – Jaakko Jun 5 '17 at 6:43
3

Have you considered using pipe and grep?

YourCommand | grep str

Hope this helps

  • 4
    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
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.