Re: find a command i have recently used in bash
On Wed, Jan 29, 2003 at 07:51:07PM +0530, Sandip P Deshmukh wrote:
> hello all
> i am sure there must be a way of doing it. i am not getting it though.
> let us say, i have done ls -l , etc etc
> then i have done a few more commands at the prompt.
> now, i want to use that ls command again. is there a way inwhich i can
> reach it quickly? for instance, i type ls and some other key and bash
> completes from history?
If you're using bash, and the command you want to retrieve was typed
in the last 500 or so commands, try "ctrl-r ls" which should recall
the most recent command with the string "ls" in it.
You can also use the "history" command to view your history. Any
command in your history can be reused by prefixing its history number
with a bang ('!'). Thus if history says "422 ls -lAF /usr/local" you
can type "!422" at a prompt to issue that command again. history +
grep can be fun.
Finally, (and perhaps most obvious) you can use ctrl-p and ctrl-n to
cycle backwards and forwards through your command history. For most
terminal types these sequences are mapped to the up-arrow and
Nathan Norman - Incanus Networking mailto:email@example.com
People demand freedom of speech to make up for the freedom of
thought which they avoid.
-- Soren Aabye Kierkegaard