Linux console - "searching" your past command history

Frosty555
Frosty555 used Ask the Experts™
on
I can't believe that this is not doable.

I'm running Ubuntu Server 10.04 at home, and at work I run Debian Lenny.

Back in the DOS days, I could partially type a command, then hit the "F8" key, and if any command I had typed in my history matched what I was typing now it would auto-complete the command to what I had typed before.

Basically it was a quick way to search my history and repeat a command I typed before.

In linux, the "up arrow" method to traverse my history works, but I have no way to "autocomplete" what I'm typing. I usually have to run the "history" command, pipe it to grep, and then copy-paste whatever I see. That is so tedious it usually is worth it to just re-type the command.

Somebody tell me there's an easy way to accomplish the "F8" shortcut that I am so used to using from DOS.

Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
It is very much possible in Linux.

Which shell are you using?  Bash or Korn?

In general you can do

history | grep -i "command"

In bash you can do

ctrl + R

And start typing your command and it starts completing your command like a web browser.
In ksh, you may have to do certain configurations to make it work.  You can also set your shell in vi mode, which is harder to use but you can find history with /command.

Also you have to set the size of your history.  If you store more, you can recall more.  For that you have to set HISTFILESIZE environment variable.

http://www.faqs.org/docs/bashman/bashref_106.html
Acronis in Gartner 2019 MQ for datacenter backup

It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.

In bash you can also do

!!

to execute your last command. You can sure use up and down arrow keys in Bash and in Ksh with certain configurations.

Commented:
The similar key is "Tab".
Top Expert 2007

Commented:
As farzanj has pointed out, Ctrl-R is what you want.

Author

Commented:
I knew there must have been a way to do it! Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial