Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a process that creates a tar file with copies of files that need to be updated.

I want to backup existing files before overwriting with the new files.

I've tried

tar cf backup.tar -T `tar tf updated.tar`

Which didn't work. If I pipe the output from tar tf to a file, then use that as the -T param it works:

tar tf updated.tar > list; tar cf backup.tar -T list

But it seems to me that I should be able to accomplish this in one command. Is it possible?

share|improve this question
up vote 3 down vote accepted

Specify stdin as input file, e.g.:

tar tf updated.tar | tar cf backup.tar -T -

share|improve this answer

The -T option is specifically looking for a file, not a list. Your first attempt passes a list to -T, which is probably why it doesn't work. I would try something like:

tar tf updated.tar | xargs tar cf backup.tar
share|improve this answer
This may fail in some rare cases. The maximum number of allowed command line arguments is restricted. See getconf ARG_MAX. – user86064 Mar 13 '13 at 17:20
Good point... so H. Dirk Schmitt's answer is probably better. – John Mar 13 '13 at 17:27
@H.-DirkSchmitt: It should be noted that xargs normally takes care of this by splitting the command in multiple invocations. (It just doesn't work as expected here since a second tar c overwrites the first output.) – grawity Mar 13 '13 at 17:36

I use this commande:

tar cf backup.tar `tar tf updated.tar`
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.