0

I was reading The complete reference: Linux and stumbled upon a text that I can't understand.

With the command line editor, not only can you edit the current command, you can also move to a previous event in the history list to edit and execute it. The CTRL-P command then moves you up to the prior event in the list. The CTRL-N command moves you down the list. The ALT-< command moves you to the top of the list, and the ALT-> command moves you to the bottom. You can even use a pattern to search for a given event. The slash followed by a pattern searches backward in the list, and the question mark followed by a pattern searches forward in the list. The n command repeats the search.

It says "slash followed by a pattern searches backward in the list", but I don't know where to type it. For example if I wanted to search for something starting with cp so where do I write /cp? And how is this different from using CTRL+R?

  • You'll have to be using the ZSh/KSh/KornSh I suspect. I believe they are Korn shell commands (Korn Shell led to ZSh or KSh). The ^R we probably all use far more often is for BASH. – guiverc Feb 16 '18 at 9:05
0

I suspect that the text that you are reading is for something called the readline library, and while it is true that the shell command line does use that library for command line manipulation and editing, the shell configures it for its own use.

If you want to experiment with the readline library's / and ? search commands, open a text file using the less browser. Your linux distribution may have already set less as its browser for man pages, so also try the search commands within a man page.

  • but how to use it to search history list? – shiva Feb 16 '18 at 6:35
  • See @guiverc's direct comment to your question. This feature is not implemented in bash. – user1404316 Feb 16 '18 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.