Help! Csh is eating my brain....
Frederick M. Avolio
avolio at decuac.UUCP
Sun Oct 20 00:15:04 AEST 1985
In article <366 at zaphod.UUCP>, flory at zaphod.UUCP (Trevor Flory) writes:
> Hello All;
> I'm trying to debug a csh script written by someone who
> knew what he was doing I'm sure. Below is a fragment of
> the script which I find rather difficult to understand:
> ...
> alias readandset 'echo -n \!:1 ; set \!:2 = $< '
> ...
> readandset "Choice? " chvar
> ...
> if("$chvar" == "quit") ....
>
> In particular I'd like to know what \!:1 or \!:2 means/does.
If you look at a command line, the first word is in position 0, the
next in position 1, and so on. !:n (where n is a non-negative number)
the csh replaces the string with the word in the nth position from the
previous command. (!:1 is the first word. !22:3 is the 3rd word from
command #22 in the history and so on....)
Example --
% ls -ld t*
drwx--x--x 16 avolio 1024 Oct 17 15:23 text
-rw-r--r-- 1 avolio 0 Oct 19 10:10 todo
% ls !:2
ls t*
todo
text:
cust.support decnet.info decuac kermit
mail paths products qpr
training uac uig ultrix11
ultrix32 venix
-----
% echo a b c
a b c
% echo !:3
echo c
c
%
And so on.....
Fred.
More information about the Comp.unix
mailing list