在 Mac OS X 上复制目录结构而不复制文件

Shr*_*saR 9 file-management macos

我想将某个目录中的目录结构复制到另一个目录中,而不复制任何实际文件。代替文件,我想要一个同名的空白文件,或者指向原始位置的符号链接。

在 OS X 上,我怎么能做到这一点?命令行工具(rsync/find/tar/whatever)、shell 脚本等都是可以接受的,我必须购买的软件可能不是。

whi*_*ark 10

user@osx:~/from$ find . -type d -exec mkdir -p ~/to/{} \;
Run Code Online (Sandbox Code Playgroud)
user@osx:~/from$ find . -type f -exec ln -s ~/from/{} ~/to/{} \;
Run Code Online (Sandbox Code Playgroud)

或者

user@osx:~/from$ find . -type f -exec touch ~/to/{} \;
Run Code Online (Sandbox Code Playgroud)


Dou*_*ris 7

试试lndir。从它的手册页:

The lndir program makes  a  shadow  copy  todir  of  a  directory  tree
fromdir,  except  that  the shadow is not populated with real files but
instead with symbolic links pointing at the real files in  the  fromdir
directory tree.
Run Code Online (Sandbox Code Playgroud)