Search code examples
macosdirectorycopyhome-directory

How to copy directories in OS X 10.7.3?


Hi I'm trying to copy my rails_projects directory from haseebjaved/Desktop/rails_projects to my home directory, which is haseebjaved.

How can I do this via the Command Line?

Also, can I see my home directory on the UI or only via the Command Line in Mac OS X?

Is it possible to copy directories to and from my home directory via the UI? Or only via Command Line?

Thank you


Solution

  • Is there something special with that directory or are you really just asking how to copy directories?

    Copy recursively via CLI:

    cp -R <sourcedir> <destdir>
    

    If you're only seeing the files under the sourcedir being copied (instead of sourcedir as well), that's happening because you kept the trailing slash for sourcedir:

    cp -R <sourcedir>/ <destdir>
    

    The above only copies the files and their directories inside of sourcedir. Typically, you want to include the directory you're copying, so drop the trailing slash:

    cp -R <sourcedir> <destdir>