How to mirror directory structure and files with zero size?
GNU cp
(from coreutils) can do this:
cp -r --attributes-only original_folder/* mirrored_folder/
From man cp:
--attributes-only
don't copy the file data, just the attributes
-R
,-r
,--recursive
copy directories recursively
Using find
command as OP says xe is on MacOS and cp
command has no --attributes-only
option:
find original_folder/ -type d -exec \
sh -c 'mkdir -p mirrored_folder/${1#*/}' _ {} \; \
-o -type f -exec \
sh -c 'touch mirrored_folder/${1#*/}' _ {} \;
Note that find
solution creates fresh directories and files unlike the cp
solution that was keeping their attributes (default: mode, ownership, timestamps).