Reading the Manual: GNU tar (Part 2)
Preamble
In my previous post, I went through the first two chapters of the GNU tar manual. Now, I move beyond the beginners' tutorial.
Observations
Section 3: Invoking GNU tar
- The old style of invoking
taruses a single letter to indicate whichtaroperation is being used. - Section 3 claims that arguments can technically be put in any order, though we saw in the tutorial that changing order of some options can cause subtle errors (though this is because some options require additional arguments, and they need to be next to each other.)
taralways operates on directories recursively- You can use globbing to access
tararchive members, but need to escape wildcard characters to keep them from being interpreted by the shell first. - While
tarhad no default operating mode, it does look for aTAR_OPTIONSenvironment variable for default options. I'm not sure how common it is to have this environment variable set, I'll have to check time I'm on something other than Windows. - Section 3.3.2 goes into detail on the different styles of flag. As with most Linux command line software, there are short versions and long versions of most options, and short options can be grouped together (so
tar --create --verbose --file=example.tar example_dir==tar -c -v -f example.tar example_dir==tar -cvf example.tar example_dir - Old-style options are similar to the modern short options, but are not preceded by a dash, and must be written clumped together. When options require arguments, like file names and locations, all options are written together, and then the arguments in the order of their corresponding options. The manual notes that this can be confusing and hard to read. This is likely the reason to have the modern argument stye.
- You can mix option styles, including old and new style options (though any old style options must come first).
- Sections 3.4.1 - 3.4.3 are a comprehensive list of operations and options, not dissimilar from what's in the man page, thought it's organized slightly differently.
- Apparently GNU
tarhas only had a man page since 2014. That seems surprisingly recent. - There's some functionality for putting checkpoints in longer archiving operations, to do things like print a percentage complete, or call an external program.
tarcan also be run interactively, so it'll ask for confirmation before reading, writing, or deleting files. Probably useful if you're worried about overwriting something.- You can supply your own arbitrary compression program.
Section 4: GNU tar Operations
- It seems that you used to be able to create an empty archive (with the intent being to use the
--appendoperation to add files later). Apparently people tended to do it by mistake and overwrite an archive they were trying to overwrite. - If you really want to create an empty archive for some reason. you could supply an empty list of files.
- You can append files to archive, and concatenate multiple archives. You can also delete members from archives, as well as update individual files (though the manual warns you not to do the latter two if you're actually working with magnetic tape).
- There's also an operation to diff archive members with the versions on the local filesystem.
- There are some options for dealing with archives written slightly differently than
targenerally expects. - There are options for controlling when and how
taroverwrites files on the local filesystem. - There's an option to extract to STDOUT or to another program.