How to copy hidden files on linux

Sometimes we need to copy a bunch of files from one directory to another on our *nix environment. 
We all know the cp command and use this in these situations. However often directories will contain hidden files or "dot files" such as .htaccess or .git.

To copy these files aswell we need to perform some matching:

cp -r SOURCEDIR/.[a-zA-Z0-9]* TARGETDIR

This will copy the hidden files in most cases.

Add new comment