[Chapter 20] 20.11 Getting tar's Arguments in the Right Order
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-10-23T15:45:02Z

#

| Chapter 20 Backing Up Files |

## 20.11 Getting tar's Arguments in the Right Order

tar's command line is one of UNIX's little mysteries. It's difficult to associate arguments with options. Let's say you want to specify the block size (b), the output file (f ), and an "exclude" file (X). Where do you put all this information? It's easy enough to stick the option letters into a lump and put them into a command (`tar cXbf`). But where do you put the block size, the name of the exclude file, and so on?

List any arguments that you need after the block of key letters. You must place the arguments in the same order as the key letters, as shown in Figure 20.1.

#### Figure 20.1: tar Options and Arguments

In this command, keepout goes with the X option, 20 goes with the b option, and archive.shar goes with the f option. If we put the options in a different order, we also have to put the arguments in a different order (see Figure 20.2).

#### Figure 20.2: The Same Command, Rearranged

Note that the files you want to put on the tape (or the files you want to extract from the tape) always go at the end of the command. These are not arguments to c or X; they are part of the command itself.

The dump command and a few others work the same way.

- ML

20.10 Avoid Absolute Paths with tar |  | 20.12 Protecting Files with SCCS or RCS