Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   CentOS (http://www.linux-archive.org/centos/)
-   -   reuse the history (http://www.linux-archive.org/centos/178213-reuse-history.html)

ann kok 10-17-2008 06:02 PM

reuse the history
 
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
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

Stewart Williams 10-17-2008 06:09 PM

reuse the history
 
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
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

Jim Wildman 10-17-2008 06:13 PM

reuse the history
 
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
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

"Filipe Brandenburger" 10-17-2008 06:20 PM

reuse the history
 
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
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


All times are GMT. The time now is 02:52 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.