img title=“I don’t know what’s worse–the fact that after 15 years of using tar I still can’t keep the flags straight, or that after 15 years of technological advancement I’m still mucking with tar flags that were 15 years old when I started.”
tar -h
I’ll take my award in all ones please
Normally I would say view the man page (as a command). Though for some reason when making the thinnest distro possible, the OS team at my job got rid of man.
Wtf man.
man wtf
tldr tar | head -n 1
If you can’t tar to a pipe into ssh to a remote host and untar into an arbitrary location there, are you really using Unix?
What the fuck lmao I didn’t know that was possible
I had to pipe dd through gzip over SSH recently to locally image a disk on a cloud server. That was fun.
Wouldn’t tar --help suffice? Afaik, it returns exit code 0.
Depends. Is it GNU tar, BSD tar or some old school Unix tar?
Double hyphen “long options” are a typical GNU thing.
That’s why those commands have two?
Yes, the terse Unix version, which needs to be supported for compatibility, and the more readable GNU long option
tar -h?
~# tar -h tar: You must specify one of the '-Acdtrux', '--delete' or '--test-label' options Try 'tar --help' or 'tar --usage' for more information. *********************************************** WARNING: Self destruct sequence initiated ***********************************************
Ugh. Bsdtar:
-h (c and r modes only) Synonym for -L.
But it has --help too.
~# tar -h || tar --help
tar -cvf CowsLookLikeMaps.tar CowsLookLikeMaps
tar xvf somearchive.tar
Is that right? )= I’m scared I lost.
Yep that’s valid.
user@server:~> tar xvf somearchive.tar
tar: somearchive.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
Scheiße…
tar --help
is a valid commandFor GNU
tar
it is, for any other versions I would not be so sure. Especially when disabling an atomic bomb.More of a request than a command, I’d have argued
I command you to show me the manual
vim -tvf
is a favorite of mine.A little trick I learned on here was to imagine yourself as a little evil man saying “Extract ze files!” in a German accent. Extract ze files >>> xzf.
That sounds a lot like Czech, “ze” means “from” if you translate it into English
Looks, not sounds. Ahoj!
I still use that. 😅
Only works for tar.gz. Remember there’s also tar.xz, tar.bz, tar.bz2 and half have their own extractor flag. FUN. It’s usually J.
I don’t remember the last time I had to worry about the compression. I simply run
tar xf myfile.tar.whatever
and it works every time.The post only calls for “a valid tar command”, not that it has to work for any specific circumstance.
xaf
(extract a file) auto-detects the format.Extract Any File
Extract All Files
I wish more people knew about dtrx (Do The Right eXtraction).
I didn’t know about
-d
.They meant the command dtrx, the combination of dtrx as parameters to tar make no sense. Extract AND append?
Or in this case, https://github.com/tldr-pages/tldr
And it’s fast implementation, https://github.com/dbrgn/tealdeer
Ayy Debian has been my main for like ten years. Dtrx is one of the ten things I apt immediately every time I have a re install
Yeah tar is easy. Regex on the other hand…
Regex, the write only language.
I can remember regex, but I need to check tar almost time.
Nothing a
.*
can’t solve
xtract ze vucking file
I’m so proud of me when I remember this. Hackerman!
Then comes a .tar.bz2 file along and you’re screwed. xtract je vucking file?
Pro tip: -z, -j are not needed by tar anymore since many years, tar will autodetect what compression was used if your distro is anything remotely modern.
Yeah I usually just do xf. 🤷♂️
You still might want to do something like alias pbtar='tar --use-compress-prog=pbzip2 to easily use pbzip2 - unless you have an ancient system that’ll speed things up significantly. And even if you don’t it’d be nice to use it for creation - to utilize more than one core the archive needs to be created for parallel extraction.
Pro tip: -z, -j are not needed by tar anymore since many years, tar will autodetect what compression was used if your distro is anything remotely modern.
😵
v is just verbose, right?
Yep.
I remember those 2 and thats all I need.
tar -extrakt ze file
tar -compress ze fileTar Xtract Ze Vucking File
Edit: apparently someone else already mentioned this, oops
Nope - it was Unix not Linux. The minus makes the command invalid on many Unix versions of tar (though most modern BSD versions allow it)
Gonna blow up then I guess
tar -extract -any -file is easier, auto detect the compression based on filename.
I think GNU tar automatically detects the compression, making
-a
unnecessary in that case.And
-z
.tar -xf foo.tar.{gz,xz,zstd,...}
will work perfectly fine.