模拟dos中的xcopy功能,实现文件的复制,当子文件夹不存在时自动创建

来源:互联网 发布:顶级域名多少类 编辑:程序博客网 时间:2024/05/18 00:15
#!/bin/sh# 模拟dos中的xcopy功能,实现文件的复制,当子文件夹不存在时自动创建
movefile(){    local file=$1    local destDir=$2    echo file=$file    echo destDir=$destDir    #     local len=`expr length $projectAbsltPath` # ¹¤³Ì·¾¶È·¶¨ºó£¬²»»áµ÷Õû     cd `dirname $file`    # »ñÈ¡ÊäÈëÎļþµÄ·¾¶£¬Ã¿¸öÎļþµÄ·¾¶¾ù¿ÉÄÜ´æÔÚ²îÒì    local fileAbsltPath=`pwd`    cd - >& /dev/null     local fileRelPath=`eval echo ${fileAbsltPath:${len}}` # »ñÈ¡Ïà¶Ô·¾¶ 20110510    fileRelPath1=`eval echo .${fileRelPath}/`  # È¥µôµÚÒ»¸ö×Ö·ûб¸Ü'/'     #echo ==fileRelPath1=$fileRelPath1        cd ${destDir}    mkdir -p ${fileRelPath1}    cd - >& /dev/null      #echo ${destDir}/${fileRelPath1}     mv ${file} ${destDir}/${fileRelPath1}}#############################################################################################projectAbsltPath=`pwd`movefile $1 $2


 

原创粉丝点击