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

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

 



On Wed, 2004-10-13 at 12:01, Bestin P. Jose wrote:
> On Sun, 10 Oct 2004 14:58:50 -0400 (EDT), Robert P. J. Day
> <rpjday@xxxxxxxxxxxxxx> wrote:
> > On Sun, 10 Oct 2004, James Wilkinson wrote:
> > 
> > > 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?
> > >
> > > Last time this came up, Ulrich Drepper pointed out the
> > > shopt -s dotglob
> > > command.
> > 
> > however, that requires a special shell option that won't work if one
> > is not using, say, bash.  a solution that uses only regular wildcards:
> > 
> > $ cp -r * .[!.]* <destdir>
> 
> 
> what about files like    ..asdf               .asdf.hewq 
                           ^^^^^^

This is a highly unusual special case, and the wildcard example above
would exclude it.
The second one you list would already be included.
These wild cards are subject to shell expansion and not regex
interpretation here.

interpreting the wildcards above would get
  *       -  anything not beginning with a dot
  .[!.]*  -  anything beginning with a dot, having 2 or more characters
in the name, and not having dot as the second character.

adding one additional wildcard would expand this to fit your example.
  ..?*    -  anything beginning with 2 dots and having at least 3
characters in the name.


There may be special cases such as your example above that would not fit
within the given wildcard globbing, but they are (in my experience)
extremely rare, and would require special consideration if your system
uses names like that.

This fits in the category of "for every rule an exception can be
defined/found".

> > 
> > why this works is left as an exercise for the viewer.
> > 
> > rday
> > 
> > --
> > fedora-list mailing list
> > fedora-list@xxxxxxxxxx
> > To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list
> >


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

  Powered by Linux