Linux tar archive without parent structure

linuxtar

I'm trying to modify a certain tar.gz archive I have.
When I go to create the tar, it retains the parent directory structure, as a tarball should. However, is there a way to simply create a tar archive with just the files I specifiy, rather than the entire directory tree?

Best Answer

Disabling recursion in tar.

POSIX pax(1) has -d option which enables cpio-like interface while allowing to create .tar files. Example from Wikipedia:

find . -depth -print | pax -wd > archive.tar

GNU tar(1) has an analogous option, --no-recursion. Example from there:

find dir tests | tar -cf archive -T - --no-recursion

P.S. I usually fall back to cpio(1) in such cases.