Spyke

GNU switched to long command switches a while ago. Try bsdtar, it's still just -h.

They kept the short ones for the actual extract/compress commands though, for compatibility reasons I presume.

7

Nope, tar spec doesn't say anything about a help message. The man spec OTOH requires at least syntax documentation for all standard utilities to be present on the system.

2
woelkchenreply
lemmy.world

Just tar, no arguments. Does nothing, still a valid command, no?

51
tar: You must specify one of the '-Acdtrux', '--delete' or '--test-label' options
Try 'tar --help' or 'tar --usage' for more information.
31
v_krishnareply
lemmy.ml

I even read this aloud in my head as "CREATE ZE VUCKING FILE" in a particularly bad German accent same as over 20 years ago when a friend I worked for drilled it in my head.

48
rockSlayerreply
lemmy.world

Yep, have this one committed to memory. Though if it asked me to uncompress a tarball, then I'd be fucked

9
thejmlreply
lemm.ee

tar xzvf this_awesome_file.tgz

… fixed. Apparently I can’t type.

9
hallettjreply
leminal.space

I think you want to remove the c because that means "create" an archive, and you're missing a z which applies gzip decompression/compression

10
_thebrain_reply
sh.itjust.works

I suppose it is tar version dependent, but on any recent Linux version I have used, you can just tar xvf <tar_name.tar.{z,gz,xz,etc}> and it will automatically figure out if it is compressed, what tools were used to compress it, and how to decompress it.

But you are right, x and c are mutually exclusive.

13

Yeap, apparently I can’t type. So, we’d all be dead anyway with that bomb.

1
lemmy.ml

It's insane that this isn't consistent.

Any combination of -h, -? and --help exists between tools (from 0 to all 3 of them)

11
zaphodreply
sopuli.xyz

Never seen -?, it's either -h, --help, or -help for programs that just want to be different.

5

I suppose I usually try -h and if that doesn't work I try the long version or the man page.

1

It's literally there at the bottom.

What isn't valid is MacOS, it's macOS now.

1
lemmy.world

Somehow, idk why. This one is stuck in my head:

tar -zxvf filename.tar.gz
45

I have to do this command often at work and I can never remember the letters perfectly. This is actually useful, thanks!

16
jlai.lu

Nope, tar doesn't handle compression on AIX. So it would be something like gzip -cd filename.tar.gz | tar xvf -

9
9point6reply
lemmy.world

Same, never used a mnemonic for it or anything, just

zxvf

Like it's any other word

2
feddit.de

z=zip (default in most tar), x=eXtract, v=verbose (not needed in most cases), f=target

2
InFerNoreply
lemmy.ml

Yeah, how do I know that the PC isn't slacking?

2
lemmy.ml

tar -xzf stands for tar eXtract Ze Filez

43
kbin.run

Depends. Short options are probably safer if the particular version and flavor of tar are unknown.

6
lemmy.world

How does it verify the command is valid? Does it run what I enter?

If so, just give it an infinite loop followed by some attempt at a tar command:

while true; do :; done; tar -xyz
27
lemmy.zip

Next time I build a bomb I let the timer continue while the command is running.

35

Blue Team: "Okay everyone let's make sure this is absolutely the correct input"

Red Team: "Lmao lets try this 90mb list of bash command injection patterns"

26
lseifreply
sopuli.xyz

i assume its looking for exit code of 0

2
lemmy.world

I'd like to know if there are any XKCDs that are no longer relevant.

22

This one, if by unix he also means modern linux systems. Nowadays you can simply use tar xf my-file.tar.whatever and it should work on most linux systems (it worked on every modern linux system I've tried and every compressed tar file I've tried). I don't think it is hard to remember the xf part.

1
lemmy.world

I hitched my horse to just what I consider the basics--zip and unzip--and that has made it easy for me. But I've been stuck on those.

Extract anything:

tar xf <archive_file>

Create a tbz2 archive:

tar cjf <archive_file.tbz2> <stuff to put in it>

(And tossing in a -v is pretty universal, if that's your thing.)

Some day, instead of commenting on a reddit Lemmy post, I think I'll Google how to tell it to use .xz.

Ok, you know what? Today is finally that day. It's just capital -J instead of lower-case -j! That's easy enough to remember, I guess.

19
lseifreply
sopuli.xyz

shouldnt there be a filename argument ?

9
lemm.ee

Yes. However, if you had skipped the -f, it would have been valid. Without the filename argument, it assumes it should extract from the tape drive (TAR = Tape ARchive). The tape device is probably something like /dev/rmt0, but you don't need to specify that. Using the -f is technically an exception which means "instead of extracting from the tape like you'd normally do, pretend that this file is the tape device instead."

5
barsoapreply
lemm.ee

GNU tar, at least a modern one, that is the one that happens to come with my system, won't try to read from /dev but stdin and then complain that it's a terminal and refuse.

Quoth POSIX on the f flag:

Use the first file operand [...] as the name of the archive instead of the system-dependent default.

That is GNU is compliant, here, the default is system-dependent. f - is required to be stdin, though, so you can bunzip2 foo.tar.bz2 | tar xf - or such in a portable manner, don't have to rely on tar having a z option (which is nonstandard) or it auto-detecting compression (even more nonstandard). What is not standard either is tar -x: Tar doesn't take leading hyphens. Tar is one of those programs so old its command line syntax got standardised before command line syntax standards were established. OTOH it's not nearly as bad as dd, you can interpret how tar does things in the same way as git pull: It's a subcommand, not a flag.

3
tisktiskreply
monero.town

"one of those programs so old its...syntax got standardized before command line syntax standards were established." --This is wild to learn, but also confusing. How does tar not take leading hyphens, but I've only ever used it as such without error of any kind? Not even bragging I've been doing that for 10+ years too lol

1

Hmm. Actually you prompted me to dig a bit deeper: tar goes all the back to Version 7 UNIX, 1979, but the command line syntax is shared with tap, included in Version 1, man page dated to 1971-11-03. Development of C started 1972. Might've been written in B, you'd have to unearth a source archive I bet it's around somewhere. But anyway if you look through the other Version 1 commands a lot of them don't take hyphen commands, ls does, e.g. rm doesn't on account of only taking file names as arguments.

dd is actually younger, Version 5, 1974, the syntax apparantly comes from IBM's JCL.

Admittedly, that's all before my time.

Both BSD and GNU tar take hyphens, I don't really have any experience with anything else but a short stint with Solaris in the early 2000s (very emphatically before Sun got gobbled up by Oracle) and I don't remember hyphens tripping me up. Much unlike killall. And I'm apparently not alone in that.

2
tisktiskreply
monero.town

I definitely still killed us all, but at the same time how are you supposed to know any of the filenames if none are given from the comic? I guess my real answer is to 'tar -xvf' then hit tab with hopes of decent file completion functionality lol

2

tar -czf $(ls | head -n1) if we dont trust globs

or run find in /bin or something

1
lemmy.world

Actually this reminds me, what is the deal with tar command recommendations to use or not use dash? I know GNU tar accepts both (e.g.) tar xvf file.tar and tar -xvf file.tar, but at some points people were like "NO! Don't use the dash! It's going to maybe cause issues somewhere, who knows!" and I was like "OK". Something to do with people up designing the Unix specs?

16
Benreply
feddit.dk

I didn't even know the dash was optional. I guess you learn something new everyday.

5

I still use it though. Its how I learned it all those years ago and its ingrained as muscle memory when typing the command.

2

POSIX. POSIX didn't get designed but documented behaviour that was portable between different UNIX flavours and was then declared a standard.

If you're annoyed by it just consider the xvf in tar xvf to be a subcommand as pull is in git pull. Tar simply has a fancy subcommand syntax. At least it's not dd.

2

No idea, but with tar I never use dashes. Just tar xf away.

2
voxelreply
sopuli.xyz

idk if it's optional why bother typing it

2

personally, it is a little easier to read, especially in a script. and its more consistent with other commands

9
m4
kbin.social

I just can recall tar xvzf but can't even remember what it's supposed to do.

15
Hawkereply
lemmy.world

eXtract, Verbose, gZip, File.

Not sure why it doesn’t need the dash though.

29
d00phyreply
lemmy.world

The dash used to be how to could tell how long someone had been using tar. If they started with Linux, they probably use a dash. If they started on a UNIX variant, they probably don’t. Either way, the dash isn’t needed.

Also recently learned that recent versions of tar will autodetect compression. So for extraction, you just need “tar xf “

16

I always learnt it as Xtract Zee File and to make a tar ball, you want to Compress Zee File

14

I guess man tar is cheating, but it is a command involving tar. Not a command using tar, but a tar command...

12
neoman4426reply
fedia.io

I suppose tar --help would technically be a valid invoking of the binary itself if man tar doesn't

13

But it would not work on older non-GNU versions of tar.

GNU introduced the "--foo" style long options, and it was a long time before Unix versions began adopting them.

3
ttrpg.network

It didn’t say you could only enter one try, just that you had 10 seconds. The man page should give you something

2
arc
lemm.ee

I know tar zxf and xjf off by heart. I probably do 100x as many extracts as creates. Tar is a stupidly antiquated command though.

9
lemmy.ml

Why remember/include the algorithm? Tar can infer that. It's just bsdtar xf filename.* for everything. (bsdtar handles .zip as well)

6

Yes, and tar works the same, it just doesn't handle zip files.

And even if we're pedantic: bsdtar is Arch Linux’ executable name for a port of the tar command that is shipped by BSDs, so it's also tar.

1
eya
lemmy.dbzer0.com

tar cJf file.tar.xz /path/to/file

tar xJf file.tar.xz /path/to/file.tar.xz -C /path/to/untar

is not very hard to remember

8

Unless you use it daily, I think that's something I'd struggle with memorising, I'd just alias it tbh along with ls options

6
fonjireply
sopuli.xyz

How do you know directory exists? 😨

2
  1. Thats not true and
  2. I am fully aware that there are 127 flags. That just makes this even sillier because you have so many valid options to disarm the bomb.
1

tar -zxvf yourmom.tgz /home/xkcd/yourmomnude/* This was wrong. I intended to be creating a file -zcvf.

6

I've never had a problem remembering tar, but properly using PV, somehow I'm just not able to store that information in my brain.

4

The fact that this thread contains, like, TONS of invalid invocations that people have been editing for correctness is fucking hilarious.

Also, QED 🤠

3

I always remember that it's eXtract Ze File, tar -xzf... But I'll be honest, I've not used it in years and years

2
touch foo; tar cvf foo.tar foo

My fucking autocorrect decided that cvf should have been xvf. I caught it before I hit enter to close out the code block, but wtf? When did my keyboard develop opinions on command args‽

1