如何在 Linux 上将 gzip 压缩的 .gz 文件重新压缩为 .xz 文件
复制并粘贴此 shell 函数到你的 bash 或 zsh:
gz_to_xz.sh
function gzToXz { zcat "$1" | xz -c - -ev9 > "${1%.*}.xz" ; }这将使用 zcat 解压文件并通过管道传给 xz,使用最高压缩设置(-ev9)。如果你更喜欢较少压缩但更快速度,使用例如 -5 代替 -ev9。
像这样使用:
gzToXz_example.sh
gzToXz my.gz这将把 my.gz 重新压缩为 my.xz。
如果你想重新压缩当前目录中的每个 .gz 文件,使用:
gzToXz_all.sh
for i in *.gz ; do echo "$i" ; gzToXz "$i" ; done即使我已经多次使用此脚本处理自己的数据,最好还是备份数据。
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow