把文件復(fù)制N份的2個(gè)Shell腳本代碼
更新時(shí)間:2014年07月10日 09:05:33 投稿:junjie
這篇文章主要介紹了把文件復(fù)制N份的2個(gè)Shell腳本代碼,一般用在需要大量文件測試時(shí)使用,需要的朋友可以參考下
測試時(shí)需要大量文件,所以寫了腳本進(jìn)行拷貝。有規(guī)律的文件名利于引用。
復(fù)制代碼 代碼如下:
#!/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
另一個(gè)版本
復(fù)制代碼 代碼如下:
#!/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
相關(guān)文章
Linux下shell腳本監(jiān)控Tomcat的狀態(tài)并實(shí)現(xiàn)自動(dòng)啟動(dòng)的步驟
這篇文章主要介紹了Linux下shell腳本監(jiān)控Tomcat的狀態(tài)并實(shí)現(xiàn)自動(dòng)啟動(dòng)的步驟,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2019-12-12
ubuntu修改terminal終端的主機(jī)名的實(shí)現(xiàn)方法
這篇文章主要介紹了ubuntu修改terminal終端的主機(jī)名的實(shí)現(xiàn)方法的相關(guān)資料,希望通過本文能幫助大家,需要的朋友可以參考下2017-08-08
用expect實(shí)現(xiàn)的自動(dòng)登錄到多臺服務(wù)器的shell腳本
自動(dòng)登錄到多臺服務(wù)器的shell腳本,用expect來實(shí)現(xiàn)的一段代碼,需要的朋友可以參考下2013-02-02
Linux 分區(qū)初始化為物理卷,把物理卷加入卷組的方法
下面小編就為大家?guī)硪黄狶inux 分區(qū)初始化為物理卷,把物理卷加入卷組的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-03-03

