Recursive copy w/ hidden files / directories
I run into this time again; I need to copy all the files from one directory to another including the hidden files and folders. Normally you’d do:
cp -r /path/to/source/dir/* /path/to/destination/dir
But bash’s glob rules won’t include hidden files/folders in the top level of the source directory. I finally found an answer over at linuxquestions.org. Just tell bash to use a different glob rule and you’re done:
shopt -s dotglob
Another commenter suggested cp -rT /path/to/source/dir /path/to/destination/dir as an alternative, but I haven’t tried it. It’s also not in the man page (at least not on my OSX machine.)