Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

With CTRL + R you can search in previous commands (in the terminal of Ubuntu). However, it always seems to display the last occurrence of the search term. Is there any way to browse through all results?

share|improve this question

migrated from stackoverflow.com Mar 19 '11 at 18:59

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

3 Answers 3

up vote 14 down vote accepted

After you type the few characters to search, you can press CTRL+R again to browse through the history that matches what you typed.

It will be limited to the history size though.

share|improve this answer
    
AWESOME! that's exactly what I was looking for! –  alfasin Oct 22 '12 at 0:52
    
For controlling history size, one can note that HISTFILESIZE controls the size of the history file (~/.bash_history), but HISTSIZE controls the size of the specific terminal history, and it is the latter that decides how far back Ctrl+R can look. I noted this on a machine where I had enlarged the former variable, but not the latter. Both are originally set to 500, but if one wants more reverse searchable history saved, both variables need to be updated. –  Daniel Andersson Oct 27 '13 at 20:34

You just need to press CTRL-R again.

share|improve this answer

If you just want to see all matching history lines at once, try fc -ln | grep.

mress:10077 Z$ fc -ln -100 | grep \^cd 
cd /Volumes/Development/android-sdk-mac_x86
cd ~/Downloads/MagicTrackpad.pkg
cd Resources
cd English.lproj
cd ../..
cd MagicTrackpadMultiTouchUpdate1.0.pkg
cd ..
cd 

(-100 means "the last 100 commands"; the default is 20, or you can specify a range.)

share|improve this answer

Your Answer

 
discard

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

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