Hi all
I want to reuse command in the shell historys Which command I can only select "traceroute 192.168.0.5" to run?
$ history |grep traceroute 26 traceroute 192.168.0.5 27 traceroute -n 192.168.0.5 28 traceroute 192.168.0.10 29 traceroute yahoo.com 46 traceroute 192.168.0.33
eg:
history |grep traceroute | awk '{ print$2 " " print$3}' | grep 26
Thank you
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
ann kok wrote:
Hi all
I want to reuse command in the shell historys Which command I can only select "traceroute 192.168.0.5" to run?
$ history |grep traceroute 26 traceroute 192.168.0.5 27 traceroute -n 192.168.0.5 28 traceroute 192.168.0.10 29 traceroute yahoo.com 46 traceroute 192.168.0.33
eg:
history |grep traceroute | awk '{ print$2 " " print$3}' | grep 26
Thank you
$ !26
On Fri, 17 Oct 2008, ann kok wrote:
Which command I can only select "traceroute 192.168.0.5" to run?
$ history |grep traceroute 26 traceroute 192.168.0.5 27 traceroute -n 192.168.0.5 28 traceroute 192.168.0.10 29 traceroute yahoo.com 46 traceroute 192.168.0.33
csh history
!26
or !26:s/168/122/ to change it
or !trac
to get #46 (or the last command to have trac at the start_
!?trace to run the last command with trace anywhere in the cmdline
fc
to invoke your $EDITOR on the last command
also !-2 (next to last)
etc
---------------------------------------------------------------------- Jim Wildman, CISSP, RHCE jim@rossberry.com http://www.rossberry.com "Society in every state is a blessing, but Government, even in its best state, is a necessary evil; in its worst state, an intolerable one." Thomas Paine
Hi,
On Fri, Oct 17, 2008 at 14:02, ann kok annkok2001@yahoo.com wrote:
I want to reuse command in the shell historys Which command I can only select "traceroute 192.168.0.5" to run?
I would type "Ctrl-R" (interactive search history starting with more recent events), then type "trace", then type "Ctrl-R" again until I find the command I'm looking for, in your case, 4 times. Once you start using "Ctrl-R" you will probably never want to use "history | grep ..." and "!..." again.
HTH, Filipe
$ history |grep traceroute 26 traceroute 192.168.0.5 27 traceroute -n 192.168.0.5 28 traceroute 192.168.0.10 29 traceroute yahoo.com 46 traceroute 192.168.0.33