I am on OS X El Capitan. I have 2 directories SourceDir
& DestDir
with the following structures.
ParentDir/SourceDir |-s_dir1/ss_dir1
|-s_dir2
ParentDir/DestDir |-s_dir1/ss_dir2
|-ddir1
|-ddir2
|-ddir3
I want to do a copy command in such a way that s_dir1
in ParentDir/SourceDir
gets merged with s_dir1
in ParentDir/DestDir
and additionally, s_dir2
gets placed into ParentDir/DestDir
. So, after the copy ParentDir/DestDir
should look like this:
ParentDir/DestDir |-s_dir1/ss_dir1
|-s_dir1/ss_dir2
|-s_dir2
|-ddir1
|-ddir2
|-ddir3
I use the following command to copy:
cp -f -R ParentDir/SourceDir/ ParentDir/DestDir/
It works all fine on MacOS Sierra. But strangely it doesn't work on an OS X machine with MacOS El Capitan. Again, I tried it with a MacOS El Capitan on my colleague's machine. It worked fine!!!
What is wrong?
Do different versions of MacOS El Capitan behave differently to cp command
?
Or, do I need to change the copy command syntax on El Capitan?
How can I do a copy command on my MacOS El Capitan machine to ensure the correct recursive copy at least on all OSX machines?
Please do not suggest to upgrade the El Capitan machine to Sierra. That is not an option for me. Hence posted this question to get some other syntax options of copy command
.
It appears that the standard cp
command is being overridden by something else. You can force it to use the standard cp
command by explicitly specifying /bin/cp
. You could also try to override the current override by using something like an alias, but it'd really be better to find out what the current override is, where it's coming from, and (maybe) getting rid of it.
The first thing to do is run type cp
its output tells you what cp
is currently doing:
cp
that's overriding the standard one... and is apparently causing problems. Your best option here is to find out what's installed the nonstandard cp
command (maybe homebrew?) and remove it.