gregs

Cycling through your history

by gregs on Jun.30, 2005, under Uncategorized

I quite often find myself cycling through the history of commands I have typed in the console window and there can be quite a few commands stored there. John, part time philosopher and all round good bloke and extraordinary at all things computing related, stopped me from monkeying around on the keyboard and showed me the following command that stopped me from having kittens when it came to finding that all important and elusive command:

CODE:
  1. history | grep "pattern"

For example while re-building qmail I was looking for the last make statement:

CODE:
  1. host:/tmp/qmail/maildrop-1.6.3# history | grep "make"
  2. 511  make man && make setup check
  3. 514  make man && make setup check
  4. 517  make cert
  5. 520  make && make setup check
  6. 528  make && make install
  7. 536  make && make install-strip
  8. 541  make && make install-strip && make install-man
  9. 547  history | grep "make"

Then you can do !541 ("!" is pronounced bang) and this will execute: "make && make install-strip && make install-man". Sometimes working with *nix systems is just so handy and it's another feather in my cap!

Oh and John see I managed to get kittens, monkeys and hats into a post!


Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!