亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

shell替換文件中的文件路徑腳本分享

 更新時間:2014年03月13日 15:01:41   作者:  
這篇文章主要介紹了shell替換文件中的文件路徑腳本,需要的朋友可以參考下

用法
參數(shù)1、寫有需要替換路徑記錄的文本,格式:老路徑 老名稱 新路徑 新名稱
參數(shù)2、需要替換的文件的目錄
參數(shù)3、需要替換的文件的類型

復(fù)制代碼 代碼如下:

#!/bin/sh

function _replace(){
basepath=$0
> $basepath.log
i=1
while read line
do
        echo "start===================================================================================" >> $basepath.log
        oldpath=`echo $line|awk '{print $1$2}'|sed 's/^\///g'`
        newpath=`echo $line|awk '{print $3$4}'|sed 's/^\///g'`
        echo $oldpath >> $basepath.log
        echo $newpath >> $basepath.log
        if [ "$oldpath" != "" ] && [ "$newpath" != "" ];then
                refiles=`grep $oldpath -irl --include="*.$3" $2`
                for refile in $refiles
                do
                        sed -i 's#'$oldpath'#'$newpath'#ig' $refile
                        echo $refile >> $basepath.log
                done
     fi
        echo "end=====================================================================================" >> $basepath.log
        echo "=">> $basepath.log
        echo $i >> $basepath.log
        echo "=">> $basepath.log
i=$(($i+1))
done < $1
}

if [ "$1" != "" ] || [ "$2" != "" ] || [ "$3" != "" ];then
_replace $1 $2 $3
else
echo "use like this:$basepath file filepath type"
fi

相關(guān)文章

最新評論