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 

相关内容