[comp.unix.questions] csh filename substitution

lawesn@SouthBank.UUCP (03/06/87)

Apologies if this question has popped up in the past but...

I was trying to rename a group of files from 'st.*' to '*'

e.g.
	st.fred.dat	=>	fred.dat
	st.jim.c	=>	jim.c
	st.nick		=>	nick

I noticed that there was (according to the csh manual) an operator :s/l/r/
which was supposed to substitute 'r' for 'l' within the filename.

So, I tried (amongst other things):

	foreach i (st.*)
	mv $i $i:s/st.//
	end

This replies with a message 'Variable syntax'

Could some kind soul out there please point out to me what I am doing wrong.
I could achieve the correct result with sed, but would like to use this
apparently nice feature (bug :-) in csh.

Thanks.

-- Nick Lawes
-- 
+--------------------------------------------------------------------------+
|  Nick Lawes (South Bank Polytechnic, UK) | ..mcvax!ukc!hrc63!kbsc!lawesn |
+------------------------------------------+-------------------------------+

chris@mimsy.UUCP (Chris Torek) (03/08/87)

In article <607@SouthBank.UUCP> lawesn@SouthBank.UUCP (Nick Lawes) writes:
>I noticed that there was (according to the csh manual) an operator :s/l/r/
>... I tried (amongst other things): ... mv $i $i:s/st.//
>This replies with a message 'Variable syntax'

(... which is one of the worst messages I have ever seen.  The syntax 
is variable?)

The :s modifier is a *history* modifier.  The only variable modifiers
are h, t, r, q, x: head, tail, root, quote, and quote-except-at-spaces.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!mimsy!chris	ARPA/CSNet:	chris@mimsy.umd.edu