3 ms·
OpenBSD, which is a fork of NetBSD, is not the only "outlier".^1 For many years, NetBSD tar has autodetected bzip2 compression. tar xzf 1.tar.bz2 will wo
by 1vuio0pswjnm7 5y ago
OpenBSD, which is a fork of NetBSD, is not the only "outlier".^1
For many years, NetBSD tar has autodetected bzip2 compression.
tar xzf 1.tar.bz2
will work on gzip as well as bzip2. Whereas GNU tar still requires "j" instead^2
tar xjf 1.tar.bz2
1. For example, FreeBSD or MacOS tar is BSD tar. It will autodetect bzip2 compression.
2. The GNU tar included with VoidLinux still requires z or j.
The pax(1) utility is the POSIX solution to these incompatibilities.
- Macha 5y agoVoid Linux appears to include GNU tar 1.34 The following should work, it worked on my Arch Linux install (but note that auto detection is not a "new" feature to GNU tar, I've been using it for at least 5 years) echo "Hello" > foo.txt tar cjf foo.tar.bz2 foo.txt rm foo.txt tar xf foo.tar.bz2 cat foo.txt and produce "Hello" To be clear, I'm not saying the following should work tar xzf foo.tar.bz2 What should work is: tar xf foo.tar.bz2 And for proof this is GNU tar $ tar --version tar (GNU tar) 1.34 Copyright (C) 2021 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by John Gilmore and Jay Fenlason.
- 1vuio0pswjnm7 5y agoIf I have a script I want to work on both BSD and Linux, and I do want to rely on uname, I usually do something like bzip2 -dc 1.tar.bz2|tar xf -