shell script to rename directory

pentium發表於2010-01-13
substr in AWK to extract string[@more@]

#!/bin/bash
for file in *
do
showname=$file

if [ -d "$file" ] # Check if it's a directory.
then
# xxxx_report echo $showname | awk '{print substr($0,1,length($0)-7)}'
# cut ?only need xxxx
targetname=`echo $showname | awk '{print substr($0,1,length($0)-7)}'`
mv $showname $targetname
echo $file "has been changed"
fi

done

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14377/viewspace-1030554/,如需轉載,請註明出處,否則將追究法律責任。

相關文章