LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 628|回复: 1

在tram兄的SHELL代码中添加了自己的代码.

[复制链接]
发表于 2006-1-4 23:30:46 | 显示全部楼层 |阅读模式
添加了一点压缩功能的代码.呵呵
#!/bin/bash
if [ -d $1 ]; then
      tar czvf $1.tar.gz    $1
      echo this is a DIR
      exit 0;
fi
UNPACK=1
if [ ${1##*.} = bz2 ] ; then
        TEMP=${1%.*}
        if [ ${TEMP##*.} = tar ] ; then
                tar jxvf $1
                UNPACK=$?
                echo This is a tar.bz2 package
        else
                bunzip2 $1
                UNPACK=$?
                echo This is a bz2 package
        fi
fi

if [ ${1##*.} = gz ] ; then
        TEMP=${1%.*}
        if [ ${TEMP##*.} = tar ] ; then
                tar zxvf $1
                UNPACK=$?
                echo This is a tar.gz package
        else
                gunzip $1
                UNPACK=$?
                echo This is a gz package
        fi
fi

if [ ${1##*.} = tar ] ; then
        tar xvf $1
        UNPACK=$?
        echo This is a tar package
fi

if [ $UNPACK = 0 ] ; then
        echo Success!
else
        echo Maybe it is not a package or the package is damaged?
fi
发表于 2006-1-7 00:29:49 | 显示全部楼层
不错~, 其实,还可以简化的
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表