国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

把文件復制N份的2個Shell腳本代碼

2019-10-26 18:41:21
字體:
來源:轉載
供稿:網友

測試時需要大量文件,所以寫了腳本進行拷貝。有規律的文件名利于引用。


代碼如下:
#!/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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 金沙县| 甘孜县| 建湖县| 长春市| 天台县| 河津市| 城固县| 丹巴县| 鄂尔多斯市| 开封县| 浙江省| 蒙山县| 大化| 寿宁县| 武鸣县| 繁昌县| 谷城县| 团风县| 神农架林区| 西充县| 平果县| 友谊县| 明星| 武胜县| 辰溪县| 西城区| 水富县| 宁德市| 高陵县| 北安市| 集贤县| 大名县| 新沂市| 长垣县| 扬中市| 泸水县| 大宁县| 遵义县| 龙岩市| 项城市| 永登县|