points by chubot 6 years ago

The way I remember tar syntax is to use it more like a "normal" command. That is, instead of the convenient but cryptic idiom:

    tar xvf foo.tar.gz  # extract, verbose, file

I use the longer but more readable stream idiom:

    tar -x -z < foo.tar.gz
    tar --verbose -x --xz < foo.tar.xz

(It does force you to specify -z for gzip or --xz for .xz, but I'm OK with that redundancy in the name of readability.)

This makes it easier to remember the syntax for create and list too:

    $ tar --create e.txt k.txt  > out.tar

    $ tar --list < out.tar 
    e.txt
    k.txt

That's how I write the install instructions for Oil:

https://www.oilshell.org/release/0.8.pre2/doc/INSTALL.html

-----

So basically tar can behave normally (at least GNU tar can) -- it's just that there's an ancient idiom that most people have in their fingers, and that's copied around in various instructions.

The nice thing about the verbose way is that the hyphen prefix enables autocomplete.

jcelerier 6 years ago

I prefer my mnemonics :

    tar caf foo.tar.gz foo/ bar/ # Compress As Fuck
    tar xaf foo.tar.gz           # Xtract As Fuck