3

I come from Linux. I keep making mistakes when I do cp -R /dir/ . instead of cp -R /dir .. These two commands are identical in Linux world, but different in MacOS. In cp manpage:

If the source_file ends in a /, 
the contents of the directory are copied rather than the directory itself. 

Since I always use Tab autocomplete the directory name and it always has / in the end, I really mean copying the directory, not the contents of the directory. I don't always remember to delete the / suffix. How do MacOS developers avoid these kind of mistakes? Thanks.

1 Answer 1

2

If you use homebrew, you can install the coreutils package, which provides GNU cp (gcp), which behaves the way you are familiar with. Then, you could set

alias cp=/path/to/homebrew/gcp

in your profile to prefer that version.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .