文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>qingmin兄的autuunzip脚本

qingmin兄的autuunzip脚本

时间:2007-11-14  来源:woshiliumang

#!/bin/bash
#
# Filename   : autounzip
# Description: Uncompress files, and print "OK" out if the file
#              can be uncompressed successfully.

# Author     : Liu Qingmin
# Syntax     : autounzip <target>
# Support    : *.tar | *.zip | *.rar | *.tgz
#              *.gz  | *.bz2 | *.bz

# Handle Error Information
if [ $# != 1 ];then
        echo "Usage:`basename $0`:*.tar|*.zip|*.tgz|*.gz|*.bz|*.bz2]"
        exit 1
fi

# Assign the parameter to the Macro OPT
OPT=$1

# Uncompress files
case $OPT in
*.tar)
        tar xvf $OPT && echo "OK"
        ;;
*.tar.Z)
        tar zxvf $OPT && echo "OK"
        ;;
*.zip)
        unzip $OPT && echo "OK"
        ;;
*.tgz)
        tar zxvf $OPT && echo "OK"
        ;;
*.gz)
        if echo $OPT | grep ".tar.gz" > /dev/null 2>&1; then
                tar xvzf $OPT && echo "OK"
        else
                gunzip $OPT && echo "OK"
        fi
        ;;
*.bz2)
        if echo $OPT | grep ".tar.bz2" > /dev/null 2>&1; then
                tar jxvf $OPT && echo "OK"
        else
                bunzip2 $OPT && echo "OK"
        fi
        ;;
*.bz)
        if echo $OPT | grep ".tar.bz" > /dev/null 2>&1; then
                tar jxvf $OPT && echo "OK"
        else
                bunzip2 $OPT && echo "OK"
        fi
        ;;
*)
        echo "File $OPT cannot be uncompressed with autounzip"
        ;;
esac

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载