I'm a Linux guy and I'm used to copying directory trees with cp -a
. OS X doesn't have -a
option on cp
... but it does have the ditto
command. I'm reading the man on ditto
now, but is there anything I should specifically be looking out for?
According to the cp man page cp -a is the same as cp -dpR which is
-p = preserve mode,ownership,timestamps
-R = recursive
-d = no dereference and preserve links
The OS X equivalent would be
cp -pPR
-p = preserve
-R = recursive
-P = no symbolic links are followed -- can be added but this is the default behavior
The only thing missing is -d which I think is the default behavior but I'm not positive.
I've never messed with ditto
Edit -- @SoloBold
-L follows symbolic links. -p does NOT follow symbolic links. OS X (10.4 at least) has no -d option.
that is a huge difference.
Personally I use rsync -a
(or whatever rsync
params are called for). My two reasons are: I already know how to do this, and I need my scripts to be portable across Linux/BSD/Solaris. There are also some filesystems where rsync
is more efficient than cp
.
Sorry that's not a direct answer, I have used ditto
on BSDs but don't have any gotchas for you that aren't in the man page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With