simple question about mv

Jeff jeff at softop.UUCP
Sat Feb 4 15:45:58 AEST 1989


In article <626 at jonlab.UUCP>, jon at jonlab.UUCP (Jon H. LaBadie) writes:
> <deleted stuff about doing this>> 
> An alternative, is one command line to create a list of "root names"
> and loop through them.  For a large number of files, this could
> greatly enhance the efficiency of the processing.  Ksh users could
> improve upon this even more using the special substitution facilities
> of that shell.
> 
> 	for root in `ls *.flip | cut -d. -f1`
> 	do
> 		mv ${root}.flip ${root}.flop
> 	done
> 

Gee guys, what about csh.  I was RTFMing today (yes, and I'll admit it on
network postnews) and found ... drum roll ... the :x modifiers.  Specifically,
:r gives you the root (i.e. no extension) of a symbol.

So, I assert (yes folks, no testing), that the following is just what the 
doctor ordered

	foreach file-to-be-renamed (*$flip)
		mv $file-to-be-renamed ${file-to-be-renamed:r}.$flop
	end

And now I wait for the howls of derision.
-- 

  ----------------------------------------------------------------------------
  | Jeff Tate              |     2425 Pandora Street, Vancouver, BC, Canada  |
  | van-bc!softop!jeff     |                                 (604) 254-4583  |
  ----------------------------------------------------------------------------



More information about the Comp.unix.questions mailing list