Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

Is it possible to set an arbitrary path within a tar archive to place files which may not exist on your original filesystem? This differs from the -C switch in that I may want to take a back up of /etc/, but place it in the archive as /configurations/etc/.

share|improve this question
IIRC the -s option does that, but don't have time to write up a whole answer right now. – Chris S Sep 12 '11 at 22:30
up vote 2 down vote accepted

In GNU tar, --transform (--xform) is the option to make file name transformations. Documentation and examples can be found here

share|improve this answer
I would have seen this had I read man tar on my system rather than on!! Thanks for the answer, regex is even better than I'd hoped for. – andyortlieb Sep 13 '11 at 18:53
@andyorlieb, thanks for the input on "--xform" not working on your system, but please do not change the content of people's answers unless you have a definitive reference to back it up. Thank you. – Chris S Sep 13 '11 at 20:24
-s on OSX's tar looks similar – gman Nov 7 '15 at 6:38

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.