cp -r without hidden files

Solution 1:

You can use rsync instead of cp:

rsync -av --exclude=".*" src dest

This excludes hidden files and directories. If you only want to exclude hidden directories, add a slash to the pattern:

rsync -av --exclude=".*/" src dest

Solution 2:

You can do

cp -r SRC_DIR/* DEST_DIR

to exclude all .files and .dirs in the SRC_DIR level, but still it would copy any hidden files in the next level of sub-directories.

Solution 3:

rsync has "-C" option

http://rsync.samba.org/ftp/rsync/rsync.html

Example:

rsync -vazC  dir1 dir2