On Thu, Jul 08, 1999 at 12:52:21PM -0500, Alex Winbow wrote:
>
> What's the canonical method of renaming several files at once? In
> this case I have a directory of files ending in '.z' which I want to
> rename to ending in '.Z'.
>
> DOS command.com could do this with move/ren and wildcards, but
> that won't work under unix. Can you do it easily with a short bourne
> shell script? Something like: for each file in directory do (strip old
> extension, add new extension, pass --> to mv)?
try this in bash:
for f in *.Z
do
noext=$(echo $f | sed 's/\(.*\)\.Z$/\1/')
mv $f $noext.z
done
If you're using some other kind of bourne-like shell, you may
have to replace this syntax:
var=$(echo ...)
with this one:
var=`echo ...`
later,
- rick
--
Richard Kilgore | [EMAIL PROTECTED]
Electrical & Computer Engineering | http://lore.ece.utexas.edu/~rkilgore/
The University of Texas at Austin | (512) 471-8011
---------------------------------------------------------------------------
Send administrative requests to [EMAIL PROTECTED]