tar -vczfx123 ought to do it
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."
754
Comments84
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?
Ugh. Bsdtar:
But it has --help too.
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. 😅
tar --help
Exactly what I would have done !
This is the way
tar -xzvf archive.tar.gzeXtract Zhe Vucking File
Sorry, it was Solaris - you just blew it up (the minus is invalid on many Unix versions of tar)
Oh come on!
Inadvertent oracle attack.
xtract ze vucking file
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.
😵
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.
Yeah I usually just do xf. 🤷♂️
v is just verbose, right?
Yep.
I'm so proud of me when I remember this. Hackerman!
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?
Useless Use Of dd
What the fuck lmao I didn't know that was possible
I remember those 2 and thats all I need.
tar -extrakt ze file
tar -compress ze file
Tar Xtract Ze Vucking File
Edit: apparently someone else already mentioned this, oops
tar -extract -any -file is easier, auto detect the compression based on filename.
I think GNU tar automatically detects the compression, making
-aunnecessary in that case.And
-z.tar -xf foo.tar.{gz,xz,zstd,...}will work perfectly fine.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 -file
tar -compress -xz -file
tar --helpis a valid commandFor GNU
tarit is, for any other version 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
tar xvf somearchive.tar
Is that right? )= I'm scared I lost.
user@server:~> tar xvf somearchive.tartar: somearchive.tar: Cannot open: No such file or directorytar: Error is not recoverable: exiting nowScheiße...
Yep that's valid.
Surely
tar --helpis a valid tar command, right?tar
Done. That's a valid command, no error code, nothing. KISS!
false
💥
OK now I have to escape to really smart assery and assume that's what I meant the whole time ;)
Edit code 2 describes something that went wrong - but that something telling you that it went wrong was the tar binary which therefor most have been valid to evaluate that!
Under no circumstances did I assume that the hint towards help itself would've been an exit code 0, no sir!
To be honest: if I'd designed that bomb it would've exploded in my face for trying to be too clever.
tar --help
I know this is a meme, but I actually find
tarfairly easy to remember.tar -xf $archiveis extract filetar -czf $archive dir/is create zipped (compressed) file and the positional arguments are the files to add to the archive.And this is 99% of my usage. You can skip
-f $archiveto use stdin/stdout or use-Cto change directory (weird name but logically tar always extracts to the current directory). There is also a flag to list which I always forget and lookup each time, but I list much less often.-vis useful for verbose.Overall there are much harder commands to remember.
findalways gets me if I go beyond-name.ps,treeandls(beyond-Al) always get me to open the man page.That would be
-t, which I tend to remember as "test", as in testing to see what is inside the archive!tealdeer is a great program to have installed for easily getting a breakdown of the flags of pretty much any CLI app that at least I can ever think of!
man tar“Yeah nvm, we’re fucked”
tldr tarand you might have a chanceHaha yeah that was my second comment on this post
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
The command that I can never get right the first time is
ln. I always end up creating a dead link inside my target folder, even when I read the man page directly prior.tar xzvf file.tar.gzI got it memorized after installing gentoo over and over again from stage 3 back in 2005Same, but it all goes to shit when I need to create an archive
What if i use bing instead of google
straight to hell.
To the boiler room of hell. Allll the way down.
I think they're already there though
you wouldn’t tarball a bomb
I find it's a lot easier if you think of it in term of tapes, which is what it was originally designed for (Tape ARchiver). It's up there with makefiles for an actually really cool concept that nobody appreciates or even necessarily understands now.
(Well, I guess filesystems are the actual cool concept, from the historical perspective, but seeing the interplay with just tapes is the novel part to me)
I wish more people knew about dtrx (Do The Right eXtraction).
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
I didn't know about
-d.explainshell.com to the rescue!
They meant the command dtrx, the combination of dtrx as parameters to tar make no sense. Extract AND append?
haha, ok thanks. So https://github.com/dtrx-py/dtrx
I'd initially assumed that it was a mnemonic but yes, listing and appending and extracting together is nonsensical, as tar notes:
tar: You may not specify more than one '-Acdtrux', '--delete' or '--test-label' optionOr in this case, https://github.com/tldr-pages/tldr
And it’s fast implementation, https://github.com/dbrgn/tealdeer
At some point, I realized
tar xfis enough for extracting a file, so that's what I'm always using now.tar -tvfis a favorite of mine.I just remember zxvf, but if I have to do anything else then extract a tar.gz we’re fucked.
tldr tar | head -n 1
tar -xvf is the only one I know
And I think it was tar -cvf for creating .tar files?
7zz x *
Or just double click.
I always liked
dtrx(do the right extraction)Btw, GNU tar has long options.
I'll take my award in all ones please