The tar
command really does not have options to not store the directory structure, in line with the linux philosophy of "do one thing and do it well".
The page you refer to provides some trick to store files without the directory structure. However, these trick are very limited in their power, and require you to specify each lowest level directory that contains files. The trick will already fail if there also are files in directories in the middle of the tree. Tarring these will include the lower directories.
As such, it is not possible in a fully automated way. A more automated way would require preparing a directory containing all files from the directory tree at the top level directory first, then tar that directory. On a file system that supports linux permissions, that could be done using hard links, so no extra space is needed for the temporary copy.
You could do so with find
:
find /path/to/parent/dir -type f -exec ln {} /path/to/new/dir \;
then you can tar the directory dir
in /path/to/new
.
gzip
instead? As mentioned, tar of a single file is doing mostly nothing beneficial – kero Dec 02 '22 at 13:51