欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

 

相关标签: Bash