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?
views:
2139answers:
5From Linux cp(1):
-a, --archive same as -dpR
which is confusing, since -d appears to be equivalent to -p. Anyway, OSX has -p and -R so you could just use that.
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.
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.