1.编写脚本
#!/bin/bash
f=$2
a=$(echo $f | grep -o '{[0-9]*-[0-9]*}')
b=$(echo $a | awk -F '-' '{print $1}' | cut -c 2-)
b=${b##0}
c=$(echo $a | awk -F '-' '{print $2}' | awk -F '}' '{print $1}')
c=${c##0}
d=$(echo $f | grep -o '.*{')
d=${d%%[\{]}
e=$(echo $f | grep -o '}.*')
e=${e##[\}]}
#echo $b $c
g=$(seq $b $c)
for i in $g
do
#echo "$d$i$e"
cp $1 "$d$i$e"
done
2.运行脚本
$ ./copy.sh hello.sh hello{1-9}.sh
3.查看结果
$ ls
copy.sh hello1.sh hello2.sh hello3.sh hello4.sh hello5.sh hello6.sh hello7.sh hello8.sh hello9.sh hello.sh
网友评论