How to port this *nix-shell script to OS X? I've got a unix-shell script that's supposed to work on nix machines. This doesn't run on OS X however, due to "cp" command not defined. Changing it to "copy" didn't help.

git log -1 --pretty=format:"%h" | xargs -I %id% git diff-tree --no-commit-id --name-only -r %id% | xargs -I % cp --parents % upd/


The script should make a copy of files changed in last git commit.
Have a look at this SO thread: https://stackoverflow.com/questions/11246070/cp-parents-option-on-mac

cp is available on OS X, but it does not support the --parents option, as I guessed. Instead of using cp --parents, replace it with ditto as mentioned in the SO answer.