shell小练
程序员文章站
2022-03-04 20:41:22
...
#!/bin/bash
files=(`ls -1`)
for file in ${files[@]}
do
if [ $file = "my.sh" ];then
continue
fi
filelen=`expr length $file`
typeset leftlen=`expr $filelen - 5`
typeset leftFile=`echo $file |awk '{print substr($0,1,'$leftlen')}'`
echo "leftFile="$leftFile
typeset count=`expr $leftlen + 1`
typeset char=`echo $file |awk '{print substr($0,'$count')}' | awk '{print substr($0,1,1)}'`
echo "char="$char
mv ${leftFile}${char}".txt" "Demo"${char}"_0000.n0"
done