#!/bin/bash count=0 for file in `ls`; do count=$((${count} + 1)); mv $file `echo ${count}"."${file##*.}`; done
${file##*.} 获取后缀名
过滤掉sh脚本
#!/bin/bash count=0 for file in `ls`; do if [ ${file##*.} != "sh" ]; then count=$((${count} + 1)); mv $file `echo ${count}"."${file##*.}`; fi done ~