4 ms·
Apparently this is how to use Zstd with tar if anyone else was wondering: tar -I zstd -xvf archive.tar.zst https://stackoverflow.com/questions/45355277/how-
by filereaper 7y ago
Apparently this is how to use Zstd with tar if anyone else was wondering:
tar -I zstd -xvf archive.tar.zst
https://stackoverflow.com/questions/45355277/how-can-i-decompress-an-archive-file-having-tar-zst https://stackoverflow.com/questions/45355277/how-can-i-decom...
Hopefully there's another option added to tar that simplifies this if this compression becomes mainstream.
- viraptor 7y agotar accepts `-a` for format autodetection for a while now. You can do: tar -axf archive.tar.whatever and it should work for gz, bz2, Z, zstd, and probably more. (verified works for zstd on gnu tar 1.32)
- yjftsjthsd-h 7y agoI think that's a GNU extension, so obviously fine on Arch, but probably not on ex. MacOS (Darwin) or Alpine (busybox) by default.
- JonathonW 7y agoBSD tar on my Mac (running 10.15.2) has -a for tarfile creation (-c mode); it always autodetects the compression format in extraction mode (-z, -j, etc. are ignored if -x is specified). Not sure when either behavior would've been introduced; the somewhat-older machine I tested on (running 10.13) does not have -a but does have the autodetection behavior on extract. -I, on the other hand (which, in gnutar, specifies a compression program to run the output through), appears to actually be GNU-specific. BSD tar makes -I synonymous with -T (specifying a file containing the list of filenames to be extracted or archived). (Please don't use Zstandard if you care about cross-platform compatibility at all, though-- it's fine in controlled environments like an OS package manager, but I don't have it on my Mac, nor do I have it by default on my Ubuntu server (which is still sitting back on 16.04; I should fix that sooner or later).)
- Lammy 7y agoAs a FreeBSD user I was curious since I wouldn't want to learn to depend on an option only to find it doesn't exist in version n-1, and today I learned that FreeBSD's tar is contributed code from libarchive and not an in-tree thing like I assumed! https://github.com/freebsd/freebsd/blob/master/usr.bin/tar/Makefile#L10 https://github.com/freebsd/freebsd/blob/master/usr.bin/tar/M... Looks like that option got merged in 2013: https://github.com/freebsd/freebsd/blame/24ac2fb6ec0610e60ac18d2cf8334d2a608fe234/contrib/libarchive/tar/bsdtar.1#L148 https://github.com/freebsd/freebsd/blame/24ac2fb6ec0610e60ac... The textual libarchive changelog isn't super clear on it, and I didn't feel like digging further, but appears to have been introduced some time between libarchive 3.0.4 in 2012 and libarchive 3.1.2 in 2013: https://github.com/freebsd/freebsd/commit/366f42737cba40ceb2e83af8d17c61c0242703c5 https://github.com/freebsd/freebsd/commit/366f42737cba40ceb2...
- JonathonW 7y agoThis got me digging a little further, and (as a consequence) I just learned something new and fun: the current libarchive-based BSD tar can create and extract a ton [1] of other formats, including ZIP, RAR, and 7Zip files! That'll save me some time next time I need to extract one at the command line; I always end up having to look at unzip's man page to make sure it's actually going to do what I want, and the 7zip command line utility's kind of funky (and not installed by default most places). But 'tar -xvf filename' is permanently burned into my mind and pretty much always does exactly what I want. [1] https://www.freebsd.org/cgi/man.cgi?query=libarchive-formats&sektion=5&n=1 https://www.freebsd.org/cgi/man.cgi?query=libarchive-formats...
- _ZeD_ 7y agoWith GNU tar, the -a flag is not needed
- Carpetsmoker 7y agoYou don't need it with libarchive-based BSD tar either. It can also extract zipfiles, ISO archives, and many other formats with just "tar xf file.zip".
- qalmakka 7y agolibarchive is really awesome! I've started using bsdtar everywhere, it's so well done and polished I never felt the need to bother with anything else (same goes for bsdcpio)
- bscphil 7y agoNote that it doesn't work with compression. tar cf example.tar.zst example creates an uncompressed tar archive. tar caf example.tar.zst example creates a zstd compressed archive.
- Macha 7y agoIt's actually (at least in the implicit tar -xf foo.tar.gz) made it to all major implementations by now. OpenBSD was the sole exception last time I checked, and OpenBSD tar only untars, it won't decompress even with flags.
- kdeldycke 7y agoThanks for that tip, I was able to simplify the magic extract() function from my .bash_profile that is relying on file extension to figure the format of the archive: https://github.com/kdeldycke/dotfiles/commit/8120778f3b968a65065c31b58d9f6da04148907a https://github.com/kdeldycke/dotfiles/commit/8120778f3b968a6...
- ben0x539 7y agoUse aunpack imo: https://linux.die.net/man/1/aunpack https://linux.die.net/man/1/aunpack
- chungy 7y agotar automatically detects and supports unpacking zstd-compressed archives (as well as other compression types). there's no reason to use -x combined with other compression flags. For compression, you can use "-c -I zstd"
- cmurf 7y agoOr tar -acf blah.tar.zst blah/ -a figures it out from the filename extension, and its zst not zstd.
- xorcist 7y agoIt's not too bad to specify compression separately, as in: zstd -cd archive.tar.xst | tar xvf - it's needed anyway as soon as you step outside of what somebody made an option for, for example encryption.