Re: find a command i have recently used in bash
On Wed, 2003-01-29 at 10:28, Nathan E Norman wrote:
> 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.
I find this a helpful refinement:
$ history | sort -rn | less
--
+---------------------------------------------------------------+
| Ron Johnson, Jr. mailto:ron.l.johnson@cox.net |
| Jefferson, LA USA http://members.cox.net/ron.l.johnson |
| |
| "Fear the Penguin!!" |
+---------------------------------------------------------------+
Reply to: