主题对此进行了解释-基本上,我在Linux系统和Cygwin的Windows系统上使用了bash脚本,其中以下命令可以正常运行:
cp --parents
但是,在Mac上的终端上运行相同的命令会出现以下错误:
cp: illegal option -- -
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
我在这种情况下使用命令将文件的选择列表复制到输出目录中,并保留其目录结构:
cp --parents foo/gen1.file foo/bar/gen2.file foo/gen3.bar bar/foo/bar.file ~/my-output/
我该怎么办才能得到这种cp --parents
行为?
通过使用Rsync参数-R来复制要复制的文件的相对目录结构,我设法在MAC上合成了此命令。
句法:
rsync -R <list of files to copy> <target dir>
用法:
rsync -R foo/gen1.file foo/bar/gen2.file foo/gen3.bar bar/foo/bar.file ~/my-output/
尽管我确定使用RSYNC而不是CP可能会增加一些开销,但得到的结果相同
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句