dmo*_*oly 38 macos command-line command-line-arguments
在Linux上,我有一个--parents命令可用于cp命令,所以我可以这样做
cp --parents test/withintest/go.rb test2
Run Code Online (Sandbox Code Playgroud)
http://www.gnu.org/software/coreutils/manual/html_node/cp-invocation.html
在Mac上,我没有此选项.有没有办法在Mac上这样做?为什么这个选项不可用?
PS.--parents的目的如下:
' - parent'通过在目标目录中附加斜杠和源文件的指定名称来形成每个目标文件的名称.
给cp的最后一个参数必须是现有目录的名称.
例如,命令:
Run Code Online (Sandbox Code Playgroud)cp --parents a/b/c existing_dir将文件a/b/c复制到existing_dir/a/b/c,创建任何缺少的中间目录.
Ste*_*han 56
这也困扰了我很多.解决方法可能是使用rsync.
rsync -R test/withintest/go.rb test2
Run Code Online (Sandbox Code Playgroud)
具有相同的效果cp --parents,OS X标配rsync.
Ech*_*lon 18
您可以ditto在Mac OS X上使用该命令:
基本形式
ditto <src-path> <dst-path>
Run Code Online (Sandbox Code Playgroud)
做你想要的.还有更多选项 - 请查看手册页.
您可以cp使用MacPorts安装GNU版本。
安装MacPorts之后,您可以安装coreutils软件包:
sudo port install coreutils
Run Code Online (Sandbox Code Playgroud)
然后,你就可以使用GNU版本cp和其他核心utilitites( ,,ls 通过附加了一个命令等):datecatg
gcp --parents test/withintest/go.rb test2
Run Code Online (Sandbox Code Playgroud)
如果您希望默认使用这些GNU版本,则可以添加GNU bin更新您的路径。将以下内容添加到您的~/.bash_profile:
export PATH="/opt/local/libexec/gnubin:$PATH"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16281 次 |
| 最近记录: |