I was reading The Unix For Loop today and I found that the following code will fail in the case of a filename like anoldfilename.old:
for i in *.old
do
j=`echo $i|sed 's/old/bak/'`
mv $i $j
done
I think the following will solve that problem:
j=`basename $i .old`
p=`dirname $i`
mv $i $p/$j.bak
The right tool for the right job!
Friday, June 24, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment