本文共 605 字,大约阅读时间需要 2 分钟。
(转自:)
tar, tar.gz. tar.bz2, tar.xv等文件的压缩和解压缩参数让人实在蛋疼,
本着没有轮子就自己造的原则,写了这个脚本,欢迎拍砖.
#!/bin/bash
#Description: untar *.tar.xz , *.tar.gz, *.tar.bz2 files
#Author:Li Xiaoming
#Version:0.1
#CreateTime:2018-06-05 19:34:41
#TO be done:add support of tar and supress function
echo
"1st arg: $1"
;
CONSTOFTARXZ=
"tar.xz"
CONSTOFTARGZ=
"tar.gz"
CONSTOFTARBZ2=
"tar.bz2"
file
=$1
fileExten=
"${file#*.}"
echo
"file extenstion: $fileExten"
;
if
[
"$CONSTOFTARXZ"
=
"$fileExten"
];
then
tar
xvf $
file
elif
[
"$CONSTOFTARGZ"
=
"$fileExten"
];
then
tar
zxvf $
file
elif
[
"$CONSTOFTARBZ2"
=
"$fileExten"
];
then
tar
jxvf $
file
fi
转载地址:http://gyqkb.baihongyu.com/