随笔 - 21  文章 - 0  trackbacks - 0
<2014年7月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

常用链接

留言簿

随笔分类

随笔档案

文章分类

搜索

  •  

最新评论

阅读排行榜

评论排行榜



$1 compressed file
$2 dest path


function decompressandcopy()
{
    filepath=`echo $1 |  sed 's/[^\/]*$//'`   

不是/字符直到末尾,*表示可以是0

因此/PATH1/PATH2/输出也是对的



    #if filepath + tmp exist

    filetemppath=$filepath"tmp/"
    echo "filetemppath $filetemppath"


    if [ ! -d "$filetemppath" ]; then
       mkdir -p "$filetemppath"
    else
       echo "tmpfilepaht already exist: $filetemppath"
    fi

    #if exist
    if [ -d "$filetemppath" ]; then
       tar -zxvf $1 -C  $filetemppath
       if [ ! $? == 0  ]; then
          echo "tar -zxvf $filetemppath failed"
          return 1
       fi
    fi


    filelists=`ls $filetemppath`
    for tmpfile in $filelists
    do
        if [ ! "$tmpfile" == "" ]; then
           echo "move $filetemppath$tmpfile to $2 "
           mv $filetemppath$tmpfile $2
        fi
    done
}

posted on 2014-07-02 12:19 pizzx 阅读(105) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理