是否有使用任何类型的归档算法提取/压缩文件的实用程序?

通常我使用tar作为* .tar档案, zip/unzip用于* .zip7z用于* .7z等等…是否有一个结合所有算法的über实用程序?

以下是此实用程序的伪使用:

提取:

 $ unpack *.tar -d /home/c0rp/this_is_tar $ unpack *.rar -d /home/c0rp/this_is_rar $ unpack *.tar.gz -d /home/c0rp/this_is_targz $ unpack *.zip -d /home/c0rp/this_is_zip $ unpack *.7z -d /home/c0rp/this_is_7z 

压缩:

 $ pack some_name.tar /home/c0rp/for_tar1 /home/c0rp/for_tar2 $ pack some_name.rar /home/c0rp/for_rar1 /home/c0rp/for_rar2 $ pack some_name.tar.gz /home/c0rp/for_targz1 /home/c0rp/for_targz2 $ pack some_name.zip /home/c0rp/for_zip1 /home/c0rp/for_zip2 $ pack some_name.7z /home/c0rp/for_zip1 /home/c0rp/for_7z 

我刚刚意识到7-Zip(命令7z )可以做到这一点。 7-Zip能够提取和压缩多种类型的档案。 以下是man 7z的引用:

 DESCRIPTION 7-Zip is a file archiver with the highest compression ratio. The pro- gram supports 7z (that implements LZMA compression algorithm), LZMA2, XZ, ZIP, Zip64, CAB, RAR (if the non-free p7zip-rar package is installed), ARJ, GZIP, BZIP2, TAR, CPIO, RPM, ISO, most filesystem images and DEB formats... 

7-Zip可以提取/压缩档案,并且正在检测压缩算法本身。

这应该像你期望的那样工作:

压缩

 $ 7z a file.tar.gz file $ 7z a file.zip file $ 7z a file.7z file $ 7z a file.gzip file 

提取

 $ 7z x file.tar.gz $ 7z x file.zip $ 7z x file.7z $ 7z x file.gzip 

这里还有一点测试。 在这里,我创建了五个档案并为它们提供不同的文件扩展名

 $ cd /tmp $ touch testfile $ for alg in {zip,gzip,7z,tar.gz,rar};do 7z a testfile."$alg" testfile;done $ ls testfile* testfile.7z testfile.gzip testfile.rar testfile.tar.gz testfile.zip 

现在要检测压缩算法,我将使用binwalk实用程序。

 $ for arch in testfile.*;do binwalk "$arch" | sed -n '4p' | awk {'print $3'};done 7-zip gzip 7-zip gzip Zip 

http://packages.ubuntu.com/trusty/dtrx

智能地提取多种存档类型

安装:

 sudo apt-get install dtrx 

主页: http : //brettcsmith.org/2007/dtrx/