How to do mv *.xyz *.abc in shell script??

Lawrence H. Miller lmiller at aerospace.aero.org
Sat Sep 8 02:52:37 AEST 1990


One way to do this is to use basename.  Try something like this (for
you specific case of changing *.xyz to *.abc).

(This is a Bourne shell script.)

------------------------------ CUT HERE ------------------------------ 

for i in *.xyz
do
  a=`basename $i .xyz`
  echo moving $a.xyz to $a.abc
  mv $a.xyz $a.abc
done

Larry Miller
Aerospace Corporation
lmiller at aerospace.aero.org
213-336-5597



More information about the Comp.unix.shell mailing list