Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to copy a bunch of files/directories using a terminal command, cp. The command I'm using is:

sudo cp -r *.tests ~/Desktop

tests are directories with stuff in them. However I get a few No such file or directory errors. I'm not sure how I can get this error if I'm doing a recursive copy. If it doesn't exist, how would I be seeing it?

share|improve this question

migrated from stackoverflow.com Aug 19 '11 at 21:22

This question came from our site for professional and enthusiast programmers.

    
Which version of Unix? Do any of the filenames have spaces in them? ( I guess that shouldn't matter, but ... ?). Good luck. –  shellter Aug 19 '11 at 19:28
    
Mac OS X, some do, some don't –  JPC Aug 19 '11 at 19:31
add comment

2 Answers

If the directory you are in, or any below it, are being modified while you are doing the copy you would see that error. For example, if after you started the cp some other process deleted a file or directory.

share|improve this answer
    
I know that no other process is touching those files –  JPC Aug 19 '11 at 19:18
    
Unless your drive is going bad or something similar, I'd say it's most definitely something other process deleting those files. lsof is your friend. –  Kaleb Pederson Aug 19 '11 at 19:20
    
After running cp and seeing the files/directories that apparently don't exist, I run lsof and those files/directories are not in the list output by lsof –  JPC Aug 19 '11 at 19:36
    
Is it how cp is traversing your directories? Some symlink sending you off into the weeds? Hard to debug this type of problem without seeing the filesystem. :-/ –  qor72 Aug 19 '11 at 19:56
add comment

From the cp man page (under OS X v10.6.8):

Historic versions of the cp utility had a -r option.  This implementation
supports that option; however, its use is strongly discouraged, as it
does not correctly copy special files, symbolic links, or fifo's.

So try cp -R instead. If that doesn't do it, is there anything notable about the files it gets errors on? Do they exist? Are they AppleDouble files (metadata pseudo-files with names starting with "._")?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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