Need a file renaming facility

Jeff Bowles bowles at lll-crg.llnl.gov
Thu Apr 28 00:53:30 AEST 1988


Hmm. Hard to do directly, without hacking the shell's view of
metacharacters. Perhaps you want something like this:

rename '\(.*\).f' *.f

in which the expression is something normally given to expr(1).
Such a script would follow this form:
	#!/bin/sh
	
	ex=$1
	shift
	for f in $*
	do
		newf=`expr $f : "$ex"`
		mv $f $newf
	done
Of course you'd embellish this, make it possible to pass flags to the
mv(1) command, and provide for files with "#" in the name, but I submit
that to ignore the existing tools would not only waste your time, but
run the risk of making a new tool that doesn't fit in well with the existing
ones.

[ "Isn't it neat when you can spell your name with the different flags you've
added to a command?" -  overheard at a Usenix a while back.]

	Jeff Bowles



More information about the Comp.unix.questions mailing list