Greg's Blog

helping me remember what I figure out

Cycling Through Your History

| Comments

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]history | grep "pattern"[/code] For example while re-building qmail I was looking for the last make statement: [code]host:/tmp/qmail/maildrop-1.6.3# history | grep "make" 511 make man && make setup check 514 make man && make setup check 517 make cert 520 make && make setup check 528 make && make install 536 make && make install-strip 541 make && make install-strip && make install-man 547 history | grep "make"[/code] 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!