您现在的位置是:网站首页>列表内容
把文件复制N份的2个Shell脚本代码_linux shell_
2023-05-26 17:45:29 130人已围观
简介 把文件复制N份的2个Shell脚本代码_linux shell_
测试时需要大量文件,所以写了脚本进行拷贝。有规律的文件名利于引用。
复制代码 代码如下:
#!/bin/sh
# file name : batchcp.sh
# author: zhouhh
# Email: ablozhou@gmail.com
# Date : 2008.3.31
echo "input your file name"
read FILENAME
echo "how many times you want copy?"
read TIMES
echo "your file name is ${FILENAME}, you want to copy ${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
# file name : batchcp.sh
# author: zhouhh
# Email: ablozhou@gmail.com
# Date : 2008.3.31
echo "input your file name"
read FILENAME
echo "how many times you want copy?"
read TIMES
echo "your file name is ${FILENAME}, you want to copy ${TIMES} times."
#find . and cut the left part of the file name using ##
EXT=${FILENAME##*.}
#find . and cut the right part of the file name using %
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
点击排行
- 天天酷跑伊咪兔和布鲁哪个好 属性对比_手机游戏_游戏攻略_
- 天天飞车15倍夺宝怎么抽s车_天天飞车15倍夺宝抽s车攻略推荐_手机游戏_游戏攻略_
- 全民水浒武大郎和鲁智深哪个好 属性对比分析_手机游戏_游戏攻略_
- 全民农场公报板在什么位置_全民农场活动公告牌具体位置介绍_手机游戏_游戏攻略_
- 全民飞机大战视频刷分教程_星星战机通关视频攻略分享_手机游戏_游戏攻略_
- 雷霆战机海盗模式攻略 教你如何秒杀海盗_手机游戏_游戏攻略_
- 天天飞车暗影橘子限时返钻活动来袭_天天飞车暗影橘子返钻500活动详情_手机游戏_游戏攻略_
- 天天飞车15倍夺宝活动火热开启_天天飞车闪耀利箭升级返钻活动介绍_手机游戏_游戏攻略_
- 雷霆战机教你如何判断玩家是否使用修改器刷分_手机游戏_游戏攻略_
本栏推荐
-
天天酷跑伊咪兔和布鲁哪个好 属性对比_手机游戏_游戏攻略_
-
天天飞车15倍夺宝怎么抽s车_天天飞车15倍夺宝抽s车攻略推荐_手机游戏_游戏攻略_
-
全民水浒武大郎和鲁智深哪个好 属性对比分析_手机游戏_游戏攻略_
-
全民农场公报板在什么位置_全民农场活动公告牌具体位置介绍_手机游戏_游戏攻略_
-
全民飞机大战视频刷分教程_星星战机通关视频攻略分享_手机游戏_游戏攻略_
-
雷霆战机海盗模式攻略 教你如何秒杀海盗_手机游戏_游戏攻略_
-
天天飞车暗影橘子限时返钻活动来袭_天天飞车暗影橘子返钻500活动详情_手机游戏_游戏攻略_
-
天天飞车15倍夺宝活动火热开启_天天飞车闪耀利箭升级返钻活动介绍_手机游戏_游戏攻略_
-
雷霆战机教你如何判断玩家是否使用修改器刷分_手机游戏_游戏攻略_