Nobody wants to deliberately use the wrong compression type when extracting, so modern tar will figure out the compression itself if you just point it at a file. So tar -xf filename works on almost anything. You don’t need to remember which flag to use on a .tar.bz2 file and which one for a .tar.xz file.
I got tired of looking up the options for each possible combination of archiving + compression, so today I have a “magic” bash function that can extract almost any format.
Then for compressing, I only use zip, which doesn’t need any args other than the archive name and the thing you’re compressing. It needs -r when recursing on dirs, but unlike “eXtract” and “Ze”, that’s a good mnemonic.
One reason is that tar supports both traditional style args “tar tf <filename.tar>” and unix-style args “tar -tf <filename.tar>” but there are subtle differences in how they work.
Literally the only time I’ve ever run into that is when I was trying to manipulate the path it extracted to. In 99% of cases I’m doing tf, xf, or cf plus flags for the compression type, etc, and those differences are irrelevant.
I used something recently where it wasn’t possible to use the traditional-style args. I think it was a “diff”, which meant I needed a “-f”. It wasn’t a big deal, but, occasionally it does happen.
I’m not saying it doesn’t happen. This thread started because I said I’ve never understood why people talk like tar is some indecipherable black magic. Common tasks are easy and there’s a man page for everything else.
I’ve never understood why people are so intimidated by tar
tar -eXtract Ze Vucking File
Thanks! This will definitely help me to remember it from now on.
Me 6 months from now:
deleted by creator
Nobody wants to deliberately use the wrong compression type when extracting, so modern tar will figure out the compression itself if you just point it at a file. So
tar -xf filenameworks on almost anything. You don’t need to remember which flag to use on a.tar.bz2file and which one for a.tar.xzfile.That doesn’t give me a memorable mnemonic though.
tar -eXtract File
yeah, but then how am I supposed to remember “tar” ? :P
Tape ARchive -eXtract File
It is sticky and pretty much ruins clothes.
I got tired of looking up the options for each possible combination of archiving + compression, so today I have a “magic” bash function that can extract almost any format.
Then for compressing, I only use
zip, which doesn’t need any args other than the archive name and the thing you’re compressing. It needs-rwhen recursing on dirs, but unlike “eXtract” and “Ze”, that’s a good mnemonic.One reason is that tar supports both traditional style args “tar tf <filename.tar>” and unix-style args “tar -tf <filename.tar>” but there are subtle differences in how they work.
Literally the only time I’ve ever run into that is when I was trying to manipulate the path it extracted to. In 99% of cases I’m doing tf, xf, or cf plus flags for the compression type, etc, and those differences are irrelevant.
I used something recently where it wasn’t possible to use the traditional-style args. I think it was a “diff”, which meant I needed a “-f”. It wasn’t a big deal, but, occasionally it does happen.
I’m not saying it doesn’t happen. This thread started because I said I’ve never understood why people talk like tar is some indecipherable black magic. Common tasks are easy and there’s a man page for everything else.