Link to home
Start Free TrialLog in
Avatar of bdario
bdario

asked on

How bash shell may emulate Dos F8 or F7 history search

Hi,
i'm quite a newbye of Linux OS. I used to work with MS Windows and the relative Dos shell.
On Linux I really miss a very interesting Dos shell feature. Infact, under Dos, it is possible to write the first word(s) of a command and then press the F8 key, to search against the command history and find the last typed command beginning with that word(s).

For example, suppose that in my Dos session I type the following commands:

  dir c:\
  format a:
  del c:\test\deleteme.txt
  rename c:\test\renameme.txt c:\test\newname.txt

Now if I want to type again the command "format a:" it is only necessary to type:

  c:\>f
or
  c:\>for

and then press F8 on my keyboard to complete the sentence. I don't have to search the history by moving with the arrows on my keyboard.

Pressing F7 on a Dos prompt I can see a menu with the last typed commands, from which i can choose.

Does anyone know how to implement these features in Linux? Especially the first one (F8)?

Thanks

Dario

Avatar of sunnycoder
sunnycoder
Flag of India image

Hi bdario,

On your command prompt type !beg  where beg is the first few beginning characters of your command and bash will locate the last command beginning with same characters and execute it

Sunnycoder
Avatar of bdario
bdario

ASKER

Hi sunnycoder,
thanks for your quick reply but your solution does not implement the same feature.
Infact i cannot see which command will be executed and it's quite a risk.
Moreover, pressing again F8 in a Dos Shell, i can scroll the list of the last commands beginning with the words typed.
Thanks again
Avatar of bdario

ASKER

Thanks, it's a very long page! :)) Which paragraph in particular?
ASKER CERTIFIED SOLUTION
Avatar of jlevie
jlevie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial