通用提取器

Ame*_*ina 22 tar compression utilities

随着存档/压缩文件格式的数量不断增加,是否有一个免费/开源命令行工具来统治所有这些格式?也许有一套一致/统一的标志?(注意我对 tar 的友好隐式引用

我曾经遇到一组别名,旨在大大简化压缩/解压缩文件的任务,并绑定到tar其他实用程序,但我再也找不到了。

更新: 如何配置类似atool不用于unzip提取 zip 文件(显然无法处理大于 4GB 的文件)并改为使用的内容gunzip

$ aunpack large_file.zip
error:  Zip file too big (greater than 4294959102 bytes)
Archive:  large_file.zip
warning [large_file.zip]:  1491344848 extra bytes at beginning or within zipfile
  (attempting to process anyway)
error [large_file.zip]:  start of central directory not found;
  zipfile corrupt.
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)
aunpack: unzip ...: non-zero return-code
Run Code Online (Sandbox Code Playgroud)

Sup*_*gic 23

我使用atool。它可以完成工作。它适用于许多格式,但不是所有格式:

tar、gzip、bzip2、bzip、lzip、lzop、lzma、zip、rar、lha、arj、arc、p7zip 等。

这些压缩工具仍然需要,尽管 atool 只是它们的前端。

我特别喜欢als它提供的命令,它列出了任何支持的存档格式的内容。

atool命令使用自己的标志来提取档案(将适当的标志传递给特定的底层提取工具)。

哦,它在一些发行版的存储库中(在我的情况下是 Fedora,但我记得,当我使用 Ubuntu 时,它不在他们的存储库中。我是从 tarball 安装的。)。

存储库更新:atool 位于以下发行版的存储库中(仅检查当前版本):

  • 软呢帽
  • Debian(感谢@terdon,并且大概是像 Ubuntu 这样的衍生产品)
  • Ubuntu(qed,大概还有 Mint 之类的衍生产品)
  • 打开 Suse
  • CentOS(可能还有 RHEL)
  • 拱形Linux

我敢肯定还有其他的……似乎是最现代的发行版。

回答更新的问题“我如何配置类似 atool 的东西,不使用 unzip 来解压 zip 文件……而使用 gunzip”

编辑 atool 配置文件~/.atoolrc并添加以下行:

path_unzip /usr/bin/gunzip
Run Code Online (Sandbox Code Playgroud)

使用正确的 gunzip 程序路径。

有关可以放入此配置文件的可能变量的完整列表,请参阅手册页,其中有很多. 如果 gunzip 所需的命令行选项与 unzip 不同,您可能需要修改 atool 源 (perl) 本身。


小智 10

这是一个处理多种归档类型的小 shell 函数。

extract () {
    if [ ! -f "$1" ] ; then
        echo "'$1' does not exist."
        return 1
    fi

    case "$1" in
        *.tar.bz2)   tar xvjf "$1"   ;;
        *.tar.xz)    tar xvJf "$1"   ;;
        *.tar.gz)    tar xvzf "$1"   ;;
        *.bz2)       bunzip2 "$1"    ;;
        *.rar)       rar x "$1"      ;;
        *.gz)        gunzip "$1"     ;;
        *.tar)       tar xvf "$1"    ;;
        *.tbz2)      tar xvjf "$1"   ;;
        *.tgz)       tar xvzf "$1"   ;;
        *.zip)       unzip "$1"      ;;
        *.Z)         uncompress "$1" ;;
        *.xz)        xz -d "$1"      ;;
        *.7z)        7z x "$1"       ;;
        *.a)         ar x "$1"       ;;
        *)           echo "Unable to extract '$1'." ;;
    esac
}
Run Code Online (Sandbox Code Playgroud)

我在网上某处找到了这个函数的原始版本,并对其进行了一些修改以提取ar档案和 xz 压缩tar档案。