用shell脚本复制N份文件方法

#!/bin/sh
 
echo "Please input your file name"
 
read  FILENAME
 
echo "How many times you want copy?"
 
read TIMES
 
echo "Your file name is ${FILENAME}, The times you want to copy is ${TIMES} ."

EXT=${FILENAME##*.}//这个是文件的名称,例如face.jpg这里的EXT就是face
#find . and cut the right part of the file name using %
BASE=${FILENAME%.*}//这个是文件的后缀名称,例如face.jpgBAST即为jpg
echo "base:$BASE"
echo "ext:$EXT"
 

for(( i=0;i<${TIMES};i++))//这里要使用类似C语言的for语句就要进行一下操作:1)chmod 777 脚本名称.sh 2)./脚本名称.sh

do
echo "copy ${BASE}.${EXT} to ${BASE}$i.${EXT} ..."
cp "${BASE}.${EXT}" "${BASE}$i.${EXT}"//循环cope
done

你可能感兴趣的:(用shell脚本复制N份文件方法)