I'm trying to copy the contents of one directory to another using:

cp -r ~/dev/testing/app/ ~/dev/app/

It works, but it's copying over files that don't exist (at least visually).

For instance index.php is not in /dev/testing/app/, but when I do cp -r ~/dev/testing/app/ ~/dev/app/ then index.php appears in the /dev/app/ directory.

I may have had index.php in /dev/testing/app/ at one point, but I've since deleted it. Why is it still copying over to the /dev/app/ directory?

  • Does another application still have the file open? On Unix systems, deleted files aren't physically removed from the system unless and until no applications have the file open and there are no references on the filesystem such as hard links referring to it. stackoverflow.com/questions/5219896/…
    – bwDraco
    Nov 15, 2015 at 20:08
  • @bwDraco that is true, in the literal sense that the data of an unlinked but open file can still be there, but the removed directory entry for a recursive cp to find it will not be there, so it does not seem to apply. Nov 15, 2015 at 20:15
  • If he is copying from a remote system, e.g., over NFS mount, the server may still have the name in the cache as long as something has the file open. Nov 15, 2015 at 21:18
  • I'm on a mac, I don't have the previous files open.
    – evan
    Nov 17, 2015 at 15:44
  • I'm just doing it locally from one folder to another
    – evan
    Nov 17, 2015 at 15:45


You must log in to answer this question.

Browse other questions tagged .