Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cp non-hidden files only [closed]

Tags:

shell

cp

Is there a good way to run cp on the shell (MinGW, in my case) to copy only non-hidden files (i.e. files whose names do not begin with .)?

I'd like to exclude my .svn folders and their contents.

like image 613
JellicleCat Avatar asked Aug 07 '12 19:08

JellicleCat


People also ask

Does cp include hidden files?

at end of the source path is a specific cp syntax that allowes to copy all files and folders, including hidden ones.

How do I view only hidden files?

Select the Start button, then select Control Panel > Appearance and Personalization. Select Folder Options, then select the View tab. Under Advanced settings, select Show hidden files, folders, and drives, and then select OK.

How do I not copy hidden files?

Using the rsync Command It accepts two valuable options that allow us to include or exclude files during the copy: –include=PATTERN and –exclude=PATTERN. To skip hidden files and directories, we can pass the “. *” pattern to the –exclude option.


1 Answers

The shell doesn't expand * to include names starting with a dot, so:

cp * /target/directory

That won't copy the .svn directory.

If that isn't your issue (e.g. you are trying to do a recursive copy with sub-directories that contain hidden files), please clarify what you are up to.

like image 50
Jonathan Leffler Avatar answered Sep 30 '22 12:09

Jonathan Leffler