How can I copy entire directories and exclude specific files in Unix How can I copy entire directories and exclude specific files in Unix unix unix

How can I copy entire directories and exclude specific files in Unix


Put star (*) in to copy but ignore hidden files

cp -urL -r /path/to/dir/A/* /path/to/dir/B


If using bash as your shell, unset the dotglob shell option.

From man bash

dotglob If set, bash includes filenames beginning with a '.' in the results of pathname expansion.

#!/bin/bashshopt -u dotglobcp -urL /path/to/dir/A /path/to/dir/B