Solved

How bash shell may emulate Dos F8 or F7 history search

Posted on 2004-04-30
5
441 Views
Last Modified: 2013-12-15
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

0
Comment
Question by:bdario
5 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10958465
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
0
 

Author Comment

by:bdario
ID: 10958524
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
0
 
LVL 17

Expert Comment

by:owensleftfoot
ID: 10959129
0
 

Author Comment

by:bdario
ID: 10959191
Thanks, it's a very long page! :)) Which paragraph in particular?
0
 
LVL 40

Accepted Solution

by:
jlevie earned 250 total points
ID: 10959448
In the bash shell you can use Ctrl-r to start an incremental reverse search through the command history. Simply type in part of the command and use additional Ctrl-r's if the first match isn't the one you want.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
linux ssh 4 59
LINUX CENTOS + APACHE 9 65
Can't See Site After DNS Resolved 7 47
expectj telnet failing 5 26
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now