Linux Smart 解压文件

字体大小: 中小 标准 ->行高大小: 标准
#!/bin/bash 
# 概要文件类型自动解压 
ftype=`file "$1"` 
case "$ftype" in 
    "$1: Zip archive"*) 
        if [ -z "$2" ]; then 
            unzip "$1" 
        else 
            unzip "$1" -d "$2" 
        fi 
        ;; 
    "$1: gzip compressed"*) 
        if [ -z "$2" ]; then 
            tar -zxvf "$1" 
        else 
            tar -zxvf "$1" -C "$2" 
        fi 
        ;; 
    "$1: bzip2 compressed"*) 
        if [ -z "$2" ]; then 
            tar -jxvf "$1" 
        else 
            tar -jxvf "$1" -C "$2" 
        fi 
        ;; 
    *) echo "File $1 can not be uncompressed with smartzip";; 
esac 

此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/58725.html