OT (ish): How to copy hidden files/directories
Mark Mielke
mark at mark.mielke.cc
Sat Oct 9 18:21:20 UTC 2004
On Sat, Oct 09, 2004 at 02:11:09PM -0400, Robert P. J. Day wrote:
> On Sat, 9 Oct 2004, Mike Noble wrote:
> >Scot L. Harris wrote:
> >>On Sat, 2004-10-09 at 03:47, CB wrote:
> >>>I can't figure out how to do this: copy (or move) all the hidden files
> >>>and directories contained in one directory to another directory.
> >>>Is it as embarrasingly simple as I imagine it must be?
> >>cp .* /newdirectory
> >>That will copy all hidden files (files that start with .) to a new
> >>directory.
> >>You can combine that with other options of cp. Check the man for cp page
> >>for those.
> >This is a really bad example. .* will also copy . and ..
> >If you want to make sure that you only copy the dot files
> >in a directory you want to use the command:
> >cp -Ra .??* /newdirectory
> and what if you have a hidden file (or directory) named ".a"?
For ZSH users:
In filename generation, the character '/' must be matched explicitly;
also, a '.' must be matched explicitly at the beginning of a pattern or
after a '/', unless the GLOB_DOTS option is set. No filename genera-
^^^^^^^^^^^^^^^^^^^
tion pattern matches the files '.' or '..'. In other instances of pat-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tern matching, the '/' and '.' are not treated specially.
Therefore, just use ".*" and don't worry about it.
I highly recommend ZSH. I don't recall a single time that I have ever
regretted switching to ZSH around 10 years ago. The behaviour just tends
to be what you want for all of its features.
Cheers,
mark
--
mark at mielke.cc/markm at ncf.ca/markm at nortelnetworks.com __________________________
. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder
|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ |
| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada
One ring to rule them all, one ring to find them, one ring to bring them all
and in the darkness bind them...
http://mark.mielke.cc/
More information about the fedora-list
mailing list