How to search for all relevant previous commands using ctrl + R on Linux

I was looking for a way to list all the previous commands matching a particular input. For example, I am in the following working directory

[root@kayan /home]#

Now I am looking for the previous command, for example.

less /home/kayan/scripts/ave.sh

So, when I pressed ctrl + R and typed ave.sh, it only shows my last used command ie

(reverse-i-search)`ave.sh': vi ave.sh

I need a method to see all previous commands that match ave.sh

+4
source share
2 answers

If you press Ctrl + R and enter your search, you will get the last record matching this search.

If you press Ctrl + R again, you will get the previous entry. You can press Ctlr + R again to get older matches.

.

+2

, Ctrl + R, history :

man history:

NAME
       history - GNU History Library

~/.bashrc, .

:

h() { history | grep "$1" | grep "$2" | grep "$3" | head -10 | sed 's/[^ ]*  //'; }

. ( sed )

+2

Source: https://habr.com/ru/post/1599428/


All Articles