[macos] OS X cp command in Terminal - No such file or directory

this might be one of those days my brain just does not work, or i'm incredibly dumb. i've been trying to copy files (which are actually directories .app, .bundle, etc.) but consistently get an error 'No such file or directory'. i've tried every possible combination of using no / slash, using the file name, using no file name. help! :/

original directory: ~/desktop/directory/file.bundle

destination directory: /library/application\ support/directory

so in otherwords, the file.bundle needs to go in that ^ directory

tried:

# cp $HOME/Desktop/directory/file.bundle /library/application\ support/directory
cp: /Users/airhead/Desktop/directory/file.bundle: No such file or directory

# cp -rf ~/desktop/directory/file.bundle /library/application\ support/directory/ 
cp: /Users/airhead/Desktop//directory/file.bundle: No such file or directory

# cd ~/

# cp -r directory/file.bundle /library/application\ support/directory/file.bundle
cp: /Users/airhead/Desktop/directory/file.bundle: No such file or directory

# cp -Rf $HOME"/directory/file.bundle" "/library/application\ support/directory/"
cp: directory /Library/Application\ Support/directory/ does not exist

additional info:

# ls -la $HOME/Desktop/directory/
ls: /Users/airhead/Desktop/directory/: No such file or directory

This question is related to macos terminal cp

The answer is


I know this question has already been answered, but another option is simply to open the destination and source folders in Finder and then drag and drop them into the terminal. The paths will automatically be copied and properly formatted (thus negating the need to actually figure out proper file names/extensions).

I have to do over-network copies between Mac and Windows machines, sometimes fairly deep down in filetrees, and have found this the most effective way to do so.

So, as an example:

cp -r [drag and drop source folder from finder] [drag and drop destination folder from finder]


On OS X Sierra 10.12, None of the above work. cd then drag and drop does not work. No spacing or other fixes work. I cannot cd into ~/Library Support using any technique that I can find. Is this a security feature?
I'm going to try disabling SIP and see if it makes a difference.


In my case, I had accidentally named a folder 'samples '. I couldn't see the space when I did 'ls -la'.

Eventually I realized this when I tried tabbing to autocomplete and saw 'samples\ /'.

To fix this I ran

mv samples\  samples

Examples related to macos

Problems with installation of Google App Engine SDK for php in OS X dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac Could not install packages due to an EnvironmentError: [Errno 13] How do I install Java on Mac OSX allowing version switching? Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) How can I install a previous version of Python 3 in macOS using homebrew? Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"

Examples related to terminal

Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave Flutter command not found VSCode Change Default Terminal How to switch Python versions in Terminal? How to open the terminal in Atom? Color theme for VS Code integrated terminal How to edit a text file in my terminal How to open google chrome from terminal? Switch between python 2.7 and python 3.5 on Mac OS X

Examples related to cp

How to copy a file from remote server to local machine? How to force 'cp' to overwrite directory instead of creating another one inside? OS X cp command in Terminal - No such file or directory How to move or copy files listed by 'find' command in unix? Copy all files with a certain extension from all subdirectories How do I copy folder with files to another folder in Unix/Linux? CentOS: Copy directory to another directory Linux how to copy but not overwrite? How to force cp to overwrite without confirmation Copy or rsync command