Skip to main content
3 of 3
word wrap for readability
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

order of (GNU) tar arguments under old style syntax?

In a shell pipeline, I compose a tar archive from a selection of files under a directory, taking the list of files from stdin, and write the archive to stdout. When I run tar like this:

tar cCTf directory - -

everything is fine. But when I try to run it like this:

tar cTCf - directory -

tar does not find the files, and I get the following error message:

tar: The following options were used after any non-optional
arguments in archive create or update mode.  These options
are positional and affect only arguments that follow them.
Please, rearrange them properly.
tar: -C ‘directory' has no effect

What is wrong with the second command?

I am running GNU tar 1.34.

toomas
  • 170
  • 7