SVR4 /bin/sh BUG

Paul Davey pd at x.co.uk
Tue Jun 25 18:09:07 AEST 1991


>>>>> On 21 Jun 91 17:17:11 GMT, pjh at mccc.edu (Pete Holsberg) said:

Pete> In article <PD.91Jun19125339 at powys.x.co.uk> pd at x.co.uk (Paul Davey) writes:
Pete> =Also ksh doesn't have the ability to refer to !-5:3 (not that I do
Pete> =this very often but !131$ or !132* are very useful.

Pete> What do they mean?

Csh substitutions beginning with ! are history substitutions

The general form is (see csh(1) for accuracy - this is from memory)

	!<command specifier>[:]<modifier>...

In many cases the : is optional.

!131 means place the whole of command 131 on the command line, so with
no other text it just repeats command 131.

As well as absolute numbers as shown by the history command relative
numbers may be used. !:-3 is replaced by the command before last. !:-2
and !:-1 by the previous command. The !! command is also a sysnonym
for !:-2 (or !-1).

I find the absolute references more useful than the relative, of which
I usually only use !!. 

[ Note: !?foo can be used as a reference to the last command containing
the string foo, !bar refers to the last command starting with bar. ]

Possible modifiers include numbers which represent elements of the command

!<cs>:0 arg0
!<cs>:1 first argument
!<cs>:2 second argument
etc

!<cs>:$ last argument
!<cs>:* all argument

Colons can generally be omited where possible

so

 !131$ means the last argument of command 131
 !132* means the all arguments of command 132

 !-5:3 means the third argument of the fifth previous command
	(includes the command line under constructiuon)

Other modifiers may be used, :p is very useful, when added it makes
the whole command line Print, so it can be checked before execution.

It is added to the history list and can be executed with !!.

!*, !$, !?<string>* are all useful forms, if you know the rules.

eg 

1	vi verylongname.c foobar.c
2	cc -g !$
3	a.out
4	dbx !!
5	!!
6	vi !cc:$
7	indent !1*

--
 Regards,			 pd at x.co.uk          IXI Limited
	Paul Davey		 pd at ixi.uucp         62-74 Burleigh St.
				 ...!uunet!ixi!pd    Cambridge  U.K.
 "These are interesting times"   +44 223 462 131     CB1  1OJ      
				 USA: 1 800 XDESK 57



More information about the Comp.unix.amiga mailing list