3

I have just now pull some git changes from remote and its a very long log. I want to look some files in the log.

But there is no option to search in the terminal window.

How can I search like we do in windows, there we have find in right click edit menu ?

4
  • 1
    mate-terminal has a search tab in menu... – Zanna Oct 25 '16 at 11:50
  • oops yes very right – justnajm Oct 25 '16 at 11:54
  • So does gnome-terminal (in the global menu, not in the right click one). – egmont Oct 25 '16 at 13:59
  • In case you are looking for a more general solution that allows you to get multiple panes/tabs, scrolling and searching in both directions in any kind of terminal or console have a look at byobu. :) – Andrea Lazzarotto Oct 25 '16 at 18:21
5

Yes, you can.

Go to:

Search -> Find...

Or use the shortcut: Ctrl+Shift+F.

You'll see a search mini-window like:

enter image description here

then this is self-explanatory i believe.

1
  • 1
    You can get a screenshot of a single window with Alt+Print Screen. It will save you the cropping step. :) – Andrea Lazzarotto Oct 25 '16 at 18:22
2

While it is possible to do this from gnome-terminal's GUI as explained by heemayl, a better way is to use the UNIX terminal itself. In general, if some command outputs lots of text that you want to search through, a useful thing is to pipe it to less.

$ some_verbose_command | less

This is a simple pager program which allows you to scroll and search through text.

Demonstration of how to view lengthy stdouts with less

To search for something within less, press / and enter the text you want (supports regexes). To skip to the next matching occurence, press n. To exit less, press q.

As a matter of fact, at least on my setup, git already shows lengthy reports by default in a less-based pager, so there's not really a need for explicitly piping it to less:

Example of how git uses a pager for lengthy output

If it doesn't do this for you, maybe you need to set

$ git config --global core.pager less

Now, this text-browsing with less is still not so different from a scrolling&searching in a GUI. Where the command line really shines though is that you can use dedicated commands to filter the output before it's ever shown on screen. The most standard tool for that is grep.

$ some_verbose_command | grep 'string_you_want'

Example display showing how grep can filter the output of git.

Once again though, you don't actually need the special tool if it's git you're talking, because it already has that kind of functionality built in.

Showing git grep in action

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.