Similarly, using (GNU) tar:
find some/dir -type d -print |
tar --no-recursion -T- -c -p -f- |
(cd another/dir && tar -x -p -f-)
You don't really need the -print0
on the find command line or the -0
on the rsync command line unless you have filenames that contain newline characters (which is possible but highly unlikely). Tar (and rsync, and cpio) read filenames line-by-line; using a NULL terminator is mostly useful with xargs
, which normally reads whitespace separated filenames (and so does not handle files/directories with spaces in their names without -0
).