将文件拷贝n份的bash脚本

测试时需要大量文件,所以写了脚本进行拷贝。有规律的文件名利于引用。

# ! / bin / sh
# filename:batchcp . sh
# author:zhouhh
# blog:http: // blog . csdn . net / ablo_zhou
# Email:ablozhou@gmail . com
# Date : 2008.3 . 31

echo " inputyourfilename "

readFILENAME

echo " howmanytimesyouwantcopy? "

readTIMES

echo " yourfilenameis${FILENAME},youwanttocopy${TIMES}times. "

BASE
= ` echo $ {FILENAME}|cut-d " . " -f 1 `
EXT
= ` echo $ {FILENAME}|cut-d " . " -f 2 `

for (( i = 0 ; i <$ {TIMES} ; i ++))
do
echo " copy${BASE}.${EXT}to${BASE}$i.${EXT}... "
cp
" ${BASE}.${EXT} " " ${BASE}$i.${EXT} "
done

另一种方式:

# ! / bin / sh
# filename:batchcp . sh
# author:zhouhh
# blog:http: // blog . csdn . net / ablo_zhou
# Email:ablozhou@gmail . com
# Date : 2008.3 . 31

echo " inputyourfilename "

readFILENAME

echo " howmanytimesyouwantcopy? "

readTIMES

echo " yourfilenameis${FILENAME},youwanttocopy${TIMES}times. "
# find . andcuttheleftpartofthefilenameusing ##
EXT
=$ {FILENAME ## * . }
# find . andcuttherightpartofthefilenameusing%
BASE
=$ {FILENAME% . *}
echo " base:$BASE "
echo " ext:$EXT "

for (( i = 0 ; i <$ {TIMES} ; i ++))
do
echo " copy${BASE}.${EXT}to${BASE}$i.${EXT}... "
cp
" ${BASE}.${EXT} " " ${BASE}$i.${EXT} "
done
~

你可能感兴趣的:(脚本,ext,Blog,bash,Gmail)