Re: OT (ish): How to copy hidden files/directories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robert P. J. Day wrote:
On Sun, 10 Oct 2004, Don Buchholz wrote:

To move only hidden (dot-) files/folders to another directory...

  # cp -pr .??* newdir

Why use ".??*" ...
* the initial "." indicates a 'hidden' file (or dot-file in Unix parlance)
* the "??" match at least two characters ... this keeps the pattern from
matching ".." which is the parent-directory
* the "*" match any number (from zero to a-lot!) of characters


which, as i pointed out earlier, won't pick up a file named ".a".


Good point. I just subscribed this morning, so I didn't see that post. The solution you posted

      $ cp -r * .[!.]* <destdir>

does solve that problem.

To be totally pedantic, though, ".[!.]*" won't match a file named
"..foofoo".  So, for completeness, we need two patterns:

      $ cp -pr .[!.]* ..?* <destdir>


- Don



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux