Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site utah-gr.UUCP Path: utzoo!linus!decvax!harpo!utah-cs!utah-gr!thomas From: thomas@utah-gr.UUCP (Spencer W. Thomas) Newsgroups: net.unix Subject: Re: mkcmd.c (in net.sources) alternate approach Message-ID: <1139@utah-gr.UUCP> Date: Tue, 10-Jul-84 12:53:47 EDT Article-I.D.: utah-gr.1139 Posted: Tue Jul 10 12:53:47 1984 Date-Received: Thu, 12-Jul-84 01:13:26 EDT References: <237@scc.UUCP> Organization: Univ of Utah CS Dept Lines: 29 Actually, Don, your second example can be done much more easily in csh than you show (it's funny how we stick with the idioms we originally learned, even when they're not appropriate). > # rename *.ftn *.ft4 > > foreach i (*.ftn) > ? mv $i `basename $i ftn`ft4 > ? end The 'mv' line can be done more efficiently as ? mv $i $i:r.ft4 In fact, the csh provides a whole set of modifiers for collecting parts of file names $i:h "Head" - strips the last component off the path. $i:t "Tail" - returns the last component of the path. $i:r "Root" - strips the part after the last '.' off the filename (or path) $i:e "Extension" - just the part after the '.' (this may be new, I don't remember it before). Examples of use (suppose $i contains '/a/b/d.c') echo $i:h -> /a/b echo $i:t -> d.c echo $i:r -> /a/b/d echo $i:e -> c =Spencer