Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

terminal

macos

cp

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
like image 416
Cocoa Puffs Avatar asked Sep 30 '13 07:09

Cocoa Puffs


2 Answers

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]

like image 187
mdhansen Avatar answered Sep 18 '22 15:09

mdhansen


Summary of solution:

directory is neither an existing file nor directory. As it turns out, the real name is directory.1 as revealed by ls -la $HOME/Desktop/.

The complete working command is

cp -R $HOME/directory.1/file.bundle /library/application\ support/directory/

with the -R parameter for recursive copy (compulsory for copying directories).

like image 23
Max Leske Avatar answered Sep 21 '22 15:09

Max Leske