simple question about mv

Rob Bernardo rob at pbhyf.PacBell.COM
Sat Jan 28 08:45:19 AEST 1989


In article <18217 at adm.BRL.MIL> DEG41560 at ua1vm.ua.edu (Rob Smith) writes:
+ I know this is simple, but then again, so am I.  What if I want to mv a bunch
+of files with the same suffix to another suffix. The following does not
+work
+
+    mv *.flip *.flop
+
+what does?  I'm under Ultrix 2.2.  I'm doing it by hand, but I'd like to
+be able to do wild card renames, ala DOS.

If you have ksh do this:

for file in *.flip
do
	mv $file ${file%%flip}flop
done

otherwise you could resort to using sed to generate the new file name,
something like this (but pardon any typos):

for file in *.flip
do
	mv $file `echo $file | sed 's/flip$/flop/'`
done
-- 
Rob Bernardo, Pacific Bell UNIX/C Reusable Code Library
Email:     ...![backbone]!pacbell!pbhyf!rob   OR  rob at pbhyf.PacBell.COM
Office:    (415) 823-2417  Room 4E750A, San Ramon Valley Administrative Center
Residence: (415) 827-4301  R Bar JB, Concord, California



More information about the Comp.unix.wizards mailing list