this post was submitted on 12 Mar 2024
10 points (100.0% liked)

Programmer Humor

35647 readers
480 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 

source

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."

top 24 comments
sorted by: hot top controversial new old
[–] [email protected] 4 points 1 year ago (1 children)

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.

[–] [email protected] 1 points 1 year ago

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.

[–] [email protected] 3 points 1 year ago

Wouldn't tar --help suffice? Afaik, it returns exit code 0.

[–] [email protected] 2 points 1 year ago

tar xzvf file.tar.gz I got it memorized after installing gentoo over and over again from stage 3 back in 2005

[–] [email protected] 1 points 1 year ago (1 children)

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?

[–] [email protected] 2 points 1 year ago

I had to pipe dd through gzip over SSH recently to locally image a disk on a cloud server. That was fun.

[–] [email protected] 1 points 1 year ago

Surely tar --help is a valid tar command, right?

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (1 children)

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.

[–] [email protected] 1 points 1 year ago
[–] [email protected] 0 points 1 year ago* (last edited 1 year ago) (1 children)

I know this is a meme, but I actually find tar fairly easy to remember.

tar -xf $archive is extract file

tar -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 $archive to use stdin/stdout or use -C to 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. -v is useful for verbose.

Overall there are much harder commands to remember. find always gets me if I go beyond -name. ps, tree and ls (beyond -Al) always get me to open the man page.

[–] [email protected] 1 points 1 year ago

There is also a flag to list which I always forget and lookup each time

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!

[–] [email protected] 0 points 1 year ago (1 children)

tar xvf somearchive.tar

Is that right? )= I'm scared I lost.

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (1 children)

user@server:~> tar xvf somearchive.tar

tar: somearchive.tar: Cannot open: No such file or directory

tar: Error is not recoverable: exiting now

[–] [email protected] 1 points 1 year ago

Scheiße...

[–] [email protected] 0 points 1 year ago (1 children)
[–] [email protected] 0 points 1 year ago (2 children)

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.

[–] [email protected] 1 points 1 year ago

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.

[–] [email protected] 1 points 1 year ago

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.

😵

[–] [email protected] 0 points 1 year ago

tar

Done. That's a valid command, no error code, nothing. KISS!

[–] [email protected] 0 points 1 year ago (1 children)

tar --help is a valid command

[–] [email protected] 0 points 1 year ago (1 children)

More of a request than a command, I'd have argued

[–] [email protected] 1 points 1 year ago

I command you to show me the manual

[–] [email protected] 0 points 1 year ago (1 children)

tar -xzvf archive.tar.gz

eXtract Zhe Vucking File

[–] [email protected] 1 points 1 year ago

Sorry, it was Solaris - you just blew it up (the minus is invalid on many Unix versions of tar)