----- "Jerry Perkins" <[email protected]> wrote:
> Dave, this is even new to me, so I am also sending it on to a couple
> others.
> 
> Reuse your history
> 
> After some time learning and experimenting at the command line, you'll
> find that you want to go back and repeat a command you executed at
> some point during the past. Luckily, Unix (and Cygwin) track every
> single command you ever type in a file called .history. Type the
> history command to see the last 100 commands you ran, which will be
> numbered, like this:

The depth of the history is configurable. Also note that the .history file is 
written on exit of the shell. So if you mistakenly type a password and it is 
captured by the shell, logout, and in again to edit the history file.
 
> Now, if you want to redo command number 87, let's say, you don't have
> to retype it. The "bang" (exclamation point) and the command number
> will get the job done. Just type !87 at the prompt, hit enter, and -
> in my case - ls | grep todo - will be re-executed.
> 
> Use grep to pick out the command of interest from your history. For
> example, to see all the ls recipes you've used in the past, grep your
> history for ls, like so:

By the time you have typed the history, grep and enough of the command to find 
it, and then issuing the bang number, you have typed way more than needed.

Use ctrl-r and start typing some portion of the command you are looking for. 
ctrl-r is a reverse history search. So it will go looking for the entry as you 
type it and show you which one it currently matches.

For a project I work with, I have to edit some files and bounce apache to see 
the changes. So I write out my vim buffer, ctrl-z to push vim suspend vim, then 
ctrl-r followed by as little as 're' to match the restart in 
'/etc/init.d/apache2 restart'  then hit enter, and fg to get back to my vim as 
soon as apache restarts.


-- 
Steven Critchfield [email protected]
-- 
You received this message because you are subscribed to the Google Groups 
"NLUG" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nlug-talk?hl=en

Reply via email to