News for hackers. Stuff that matters.
Re:Learn just enough Linux to get things done by nerdponx on Thursday November 16, 2017 @11:00AM (#15713691)
It's even easier than that! Less memorization, more understanding.

You can think of Tar arguments as either subcommands or options. The dashes are optional

The "subcommands" are x (extract), c (create), t (list), among others.

The "options" are f (read from named file rather than stdin), v (verbose mode), and z (run gzip on the archive before processing).

The fact that these options can be written without leading dashes, and all smashed together in a single argument, is legacy silliness for saving a few keystrokes. Don't confuse yourself with it, and don't confuse other people by teaching it to them, instead of teaching them how to actually use the command (which is really not hard at all).

So when I write Tar commands, I like to think along these lines. Instead of "tar zcvf foo.tar.gz", I write "tar -c -zv -f foo.tar.gz". After doing that about 3 times, it all sank in. Nowadays I'm much more intimidated by Git than Tar.

In the version of tar on the machine I'm posting from (GNU tar 1.27.1), this structure is obvious from right there in the man page:

    SYNOPSIS
       Traditional usage
           tar {A|c|d|r|t|u|x}[GnSkUWOmpsMBiajJzZhPlRvwo] [ARG...]
    
       UNIX-style usage
           tar -A [OPTIONS] ARCHIVE ARCHIVE

           tar -c [-f ARCHIVE] [OPTIONS] [FILE...]

           tar -d [-f ARCHIVE] [OPTIONS] [FILE...]

           tar -t [-f ARCHIVE] [OPTIONS] [MEMBER...]

           tar -r [-f ARCHIVE] [OPTIONS] [FILE...]

           tar -u [-f ARCHIVE] [OPTIONS] [FILE...]

           tar -x [-f ARCHIVE] [OPTIONS] [MEMBER...]
Re:Learn just enough Linux to get things done by gandreani on Thursday November 16, 2017 @12:08PM (#15714377)
Thank you! That was very useful
Re:Learn just enough Linux to get things done by aldanor on Friday November 17, 2017 @07:56AM (#15721589)
Also -j for un-bzip2-ing which comes useful quite often.