码迷,mamicode.com
首页 > 系统相关 > 详细

shell包含所有解压缩的函数

时间:2016-07-02 23:05:28      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:shell

#!/bin/sh() {
        if [ -f $1 ];then
                case $1 in
                        *.tar.bz2)      tar xjf $1      ;;
                        *.tar.gz)       tar xzf $1      ;;
                        *.bz2)          bunzip2 $1      ;;
                        *.rar)          unrar e $1      ;;
                        *.gz)           gunzip $1       ;;
                        *.tar)          tar xf $1       ;;
                        *.tbz2)         tar xjf $1      ;;
                        *.tgz)          tar xzf $1      ;;
                        *.zip)          gunzip $1       ;;
                        *.Z)            uncompress $1   ;;
                        *.7Z)           7z x $1         ;;
                        *)              echo "‘$1‘ cannot be extract()" ;;
                esac
        else
                echo "‘$1‘ is not a valid file"
        fi
}


本文出自 “走得远.看的深” 博客,谢绝转载!

shell包含所有解压缩的函数

标签:shell

原文地址:http://2462852817.blog.51cto.com/11224080/1795160

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!