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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.