If I'm on my Desktop and I have a file called 'test.txt' on there, and I want to copy that file to say '~/Library/Folder 1/Folder 2/' how do I do that? Also, if there's already a file there called 'test.txt' I'd like to replace that file.

I've tried running

cp -R ./test.txt ~/Library/Folder 1/Folder 2/ 

but that didn't do the trick.


First things first, -R is used for recursive copying, which won't do anything for a single file.

cp default behavior is to overwrite the existing file.

cp test.txt ~/Library/Folder\ 1/Folder\ 2/

The backslash is used to stop the string being split on the spaces.

You must log in to answer this question.

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