50

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

1
  • 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. Oct 2, 2013 at 17:48

7 Answers 7

19

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.

4
  • 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, 2011 at 4:56
  • Just adding that you can use Byobu which based on TMux or Screen
    – Boynux
    Nov 27, 2013 at 2:12
  • Terminator doesn't highlight text when you search for it.
    – user171453
    Mar 16, 2016 at 10:30
  • Do you happen to recall how to find text in the OS X Terminal? I'm trying to do that right now, and I'm having difficulty successfully searching out this information.
    – M. Justin
    Mar 30, 2021 at 16:16
69

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.

6
  • 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, 2011 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, 2011 at 16:31
  • Thanks SynapticUnderrun, I'll definitely look for that next time I can upgrade.
    – Joseph Johnson
    Jun 29, 2011 at 20:38
  • 1
    Just worked for me also in xfce4-terminal, (X)ubuntu Raring 13.04. Thanks. Oct 26, 2013 at 2:25
  • 7
    This should be the accepted answer. Works for me on Ubuntu 14.04 LTS.
    – user171453
    Mar 16, 2016 at 10:34
12

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

1
  • 2
    Works with default xfce4-terminal 0.6.3 on Xubuntu 16.04.
    – Jaakko
    Jun 5, 2017 at 6:43
4

Have you considered using pipe and grep?

YourCommand | grep str

Hope this helps

3
  • 5
    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, 2011 at 1:56
  • 1
    This question came up when i googled 'search terminal output' and I think this answer is great, it really helped me out (even if it technically wasn't suitable for OP)
    – Toms Code
    Jul 6, 2021 at 18:25
  • This will not work for awk | grep bugs need to use awk --help | grep bugs instead. Jul 13, 2022 at 21:11
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.

1

If you are using terminal on Mac OS, you can simply use Command ⌘ F

0

For the logs: also guake supports searching via ctrl+shift+f since https://github.com/Guake/guake/pull/1533 was merged

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.