LWN.net Logo

CLI Magic: Using command history in the bash shell (Linux.com)

CLI Magic: Using command history in the bash shell (Linux.com)

Posted Jul 4, 2006 14:39 UTC (Tue) by gjmarter (subscriber, #5777)
Parent article: CLI Magic: Using command history in the bash shell (Linux.com)

I have a command called showcmd which is implemented as follows:

history | grep "$1" | grep -v showcmd | sort -r -k 2 | uniq -f 1 | sort -n | tail

I believe it only works in bash. This allows me to quickly find the most recent commands matching a pattern without repeats.

Also if the command that I want is a small variation of one of those commands then M-^ allows me to edit the line in the shell as if it had been typed it or arrowed back to.


(Log in to post comments)

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds