OpenSource For You

Searching the command history

-

One of the greatest features of the bash shell is command history, which makes it easy to naYigate through past commands by naYigating up and down through your history with the up and down arrow keys.

This is fine if the command you want to repeat is one of the last few commands in the history you executed, but the process becomes tedious if you haYe to go through the last 75100 commands in your history to access this command.

To speed things up, you can search interactiY­ely through your command history by pressing Ctrl+R. After doing this, your prompt changes to:

(reverse-i-search)`’:

Start typing a few letters of the command you’re looking for, and bash shows you the most recent command that contains the string you’Ye typed so far. What you type is shown between the ` and ‘ in the prompt. ,n the example below, , typed in htt

(reverse-i-search)`htt’: rpm -ql $(rpm -qa | grep httpd)

This shows that the most recent command , typed containing the string htt is:

To execute that command again, , can press the Enter key or press Ctrl+R to search the next instance of it in the command history. This can be a real time saYer for people working on Command Line ,nterface.

rpm -ql $(rpm -qa | grep httpd)

—Sudhir A V , av.sudhir@gmail.com

 ??  ??
 ??  ??

Newspapers in English

Newspapers from India