linux 遍历文件添加index

#!/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
~

 

posted @ 2020-09-08 13:15  菜鸟的进击  阅读(566)  评论(0编辑  收藏  举报