I want to add a few folders (recursively) to a new tar archive. All of the folders should be at the root level of the resulting archive. Is there any way to add all folders without their parents, and without
cd-ing into their directories first and adding them step-by-step?
Consider the following directory structure
. ├── bar │ ├── bar-file │ └── barsub │ └── barsub-file └── foo ├── foo-file └── foosub └── foosub-file
I'd like to add bar and foosub to a tar archive.
# add folders with different parents # could be e.g. /some/foo/foosub and /other/bar as well $ tar cvf archive.tar bar foo/foosub a bar a bar/bar-file a bar/barsub a bar/barsub/barsub-file a foo/foosub a foo/foosub/foosub-file
but what I wanted is
. ├── bar │ ├── bar-file │ └── barsub │ └── barsub-file └── foosub └── foosub-file
Is there any easy way to create such a flat tar archive?