One shell script resolves multiple compressed files (change others' code)
The core code of this program is written by tram at linuxsir.org. It mainly aims to understand the function of compressing files in a limited time. I added some code to enable him to compress the Directory and unlock the rarfile. This shell program is very simple. I often use it to execute the program permission using chmod Gou + x filename, then copy to/bin/usr. in this way, you can use it. haha. here is the code.
#! /Bin/bash
If [-d $1]; then
Tar czvf limit 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
# Echo ${1 ##*.}
If [$ {1 # *.} = zip]; then
Unzip $1
Unpack = $?
Fi
If [$ {1 # *.} = RAR]; then
RAR x $1
Unpack = $?
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