Skip to main content

How to prepend a directory to files placed in a tar archive? [Resolved]

I want to tar the files foo and bar into a tar archive archive.tar, but I want them to appear, within the archive, as being within a directory, bazdir. Thus when I untar someplace I want bazdir to be created and foo and bar to be created within it.

How can I do that?

This would be the opposite of:
create flat tar archive: ignoring all parents when adding folders

Question Credit: einpoklum
Question Reference
Asked October 11, 2017
Posted Under: Unix Linux
1 Answers

Your Answer