this post was submitted on 12 Mar 2024
751 points (98.8% liked)

Programmer Humor

32850 readers
84 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 50 comments
sorted by: hot top controversial new old
[–] dotslashme@infosec.pub 138 points 10 months ago (1 children)

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

[–] SpaceCadet@feddit.nl 48 points 10 months ago (2 children)

Depends. Is it GNU tar, BSD tar or some old school Unix tar?

Double hyphen "long options" are a typical GNU thing.

[–] paraphrand@lemmy.world 13 points 10 months ago (1 children)

That’s why those commands have two?

[–] SpaceCadet@feddit.nl 11 points 10 months ago

Yes, the terse Unix version, which needs to be supported for compatibility, and the more readable GNU long option

[–] MonkderZweite@feddit.ch 9 points 10 months ago (1 children)
[–] SpaceCadet@feddit.nl 35 points 10 months ago* (last edited 10 months ago) (2 children)
~# 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
***********************************************

load more comments (2 replies)
[–] tkk13909@sopuli.xyz 108 points 10 months ago (4 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.

[–] Tb0n3@sh.itjust.works 25 points 10 months ago (3 children)

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.

[–] Zagorath@aussie.zone 24 points 10 months ago

The post only calls for "a valid tar command", not that it has to work for any specific circumstance.

[–] xigoi@lemmy.sdf.org 13 points 10 months ago (2 children)

xaf (extract a file) auto-detects the format.

load more comments (2 replies)
load more comments (1 replies)
load more comments (3 replies)
[–] Blackmist@feddit.uk 82 points 10 months ago (2 children)
load more comments (2 replies)
[–] PlexSheep@feddit.de 75 points 10 months ago (1 children)

tar -xzvf archive.tar.gz

eXtract Zhe Vucking File

[–] Emma_Gold_Man@lemmy.dbzer0.com 41 points 10 months ago (2 children)

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

[–] PlexSheep@feddit.de 12 points 10 months ago

Oh come on!

load more comments (1 replies)
[–] olsonexi@lemmy.world 72 points 10 months ago (3 children)
[–] chellomere@lemmy.world 29 points 10 months ago (3 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.

[–] allywilson@sopuli.xyz 21 points 10 months 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.

😵

load more comments (2 replies)
[–] victorz@lemmy.world 10 points 10 months ago (1 children)
load more comments (1 replies)
load more comments (1 replies)
[–] fubo@lemmy.world 51 points 10 months ago (2 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?

[–] LostXOR@fedia.io 29 points 10 months ago* (last edited 10 months ago) (1 children)

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

[–] JustUseMint@lemmy.world 10 points 10 months ago

What the fuck lmao I didn't know that was possible

[–] Oha@lemmy.ohaa.xyz 48 points 10 months ago (5 children)

I remember those 2 and thats all I need.
tar -extrakt ze file
tar -compress ze file

[–] noli@programming.dev 26 points 10 months ago* (last edited 10 months ago)

Tar Xtract Ze Vucking File

Edit: apparently someone else already mentioned this, oops

[–] SirQuackTheDuck@lemmy.world 13 points 10 months ago (2 children)

tar -extract -any -file is easier, auto detect the compression based on filename.

load more comments (2 replies)
load more comments (3 replies)
[–] ShaunaTheDead@fedia.io 44 points 10 months ago (3 children)

tar --help is a valid command

[–] Aganim@lemmy.world 19 points 10 months ago* (last edited 10 months ago)

For GNU tar it is, for any other version I would not be so sure. Especially when disabling an atomic bomb.

load more comments (2 replies)
[–] owatnext@lemmy.world 32 points 10 months ago (2 children)

tar xvf somearchive.tar

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

[–] bdonvr@thelemmy.club 29 points 10 months ago* (last edited 10 months 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

[–] owatnext@lemmy.world 32 points 10 months ago

Scheiße...

[–] Shadow@lemmy.ca 9 points 10 months ago

Yep that's valid.

[–] meteokr@community.adiquaints.moe 31 points 10 months ago

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

[–] Scipitie@lemmy.dbzer0.com 30 points 10 months ago (1 children)

tar

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

[–] backhdlp@iusearchlinux.fyi 52 points 10 months ago (4 children)

false

tar: You must specify one of the '-Acdtrux', '--delete' or '--test-label' options
Try 'tar --help' or 'tar --usage' for more information.
zsh: exit 2     tar
[–] Huschke@lemmy.world 25 points 10 months ago
load more comments (3 replies)
[–] kevincox@lemmy.ml 30 points 10 months ago* (last edited 10 months 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.

[–] russjr08@bitforged.space 10 points 10 months 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!

[–] kautau@lemmy.world 27 points 10 months ago (1 children)

man tar

“Yeah nvm, we’re fucked”

[–] csm10495@sh.itjust.works 21 points 10 months ago* (last edited 10 months 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.

load more comments (1 replies)
[–] SteveDinn@lemmy.ca 20 points 10 months ago

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.

[–] jpablo68@infosec.pub 13 points 10 months ago (1 children)

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

load more comments (1 replies)
[–] CanadaPlus@lemmy.sdf.org 12 points 10 months ago* (last edited 10 months ago)

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)

[–] davel@lemmy.ml 12 points 10 months ago
[–] RandomVideos@programming.dev 12 points 10 months ago (1 children)

What if i use bing instead of google

[–] baseless_discourse@mander.xyz 16 points 10 months ago (2 children)
load more comments (2 replies)
[–] Ephera@lemmy.ml 11 points 10 months ago

At some point, I realized tar xf is enough for extracting a file, so that's what I'm always using now.

[–] Bishma@discuss.tchncs.de 11 points 10 months ago* (last edited 10 months ago)

tar -tvf is a favorite of mine.

[–] HogsTooth@lemmy.world 11 points 10 months ago (5 children)

I wish more people knew about dtrx (Do The Right eXtraction).

load more comments (5 replies)
load more comments
view more: next ›