Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

unix

cp

I have a Unix batch script that copies the contents of one directory (call it dir A) to another (call it dir B).

Here is the copy statement I have currently.

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

However, this statement copies over hidden files.

How can I exclude any and all hidden files from being copied over?

like image 394
James P. Avatar asked Jan 20 '23 06:01

James P.


1 Answers

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

cp -urL -r /path/to/dir/A/* /path/to/dir/B
like image 119
ngduc Avatar answered Jan 30 '23 00:01

ngduc