How to do mv *.xyz *.abc in shell script??
Chet Ramey
chet at cwns1.CWRU.EDU
Sat Sep 8 03:55:36 AEST 1990
changing *foo to *bar
>in csh it's even easier
>
>foreach i ( *foo )
> mv $i {$i:r}.bar
>end
In bash or ksh, it's just as easy:
cwns1$ ls
1.foo 2.foo 3.foo 4.foo 5.foo 6.foo 7.foo 8.foo 9.foo
cwns1$ for i in *.foo
> do
> mv $i ${i%.*}.bar
> done
cwns1$ ls
1.bar 2.bar 3.bar 4.bar 5.bar 6.bar 7.bar 8.bar 9.bar
Chet
--
Chet Ramey ``Levi Stubbs' tears run down
Network Services Group his face...''
Case Western Reserve University
chet at ins.CWRU.Edu
More information about the Comp.unix.shell
mailing list