Re: [Help-bash] How to safely work on files/dirs with .
From:
Greg Wooledge
Subject:
Re: [Help-bash] How to safely work on files/dirs with .
Date:
Mon, 14 Mar 2016 08:40:54 -0400
User-agent:
Mutt/1.4.2.3i
On Mon, Mar 14, 2016 at 03:17:48AM +0000, Stephane Chazelas wrote:
> 2016-03-12 18:48:37 -0700, Bob Proulx:
> [...]
> > If you want the bash way for matching characters that are not a dot:
> >
> > chown -R test:test /home/test/.[!.]*
> [...]
>
> Note that it misses files like ..foo or ... (you'd need to add
> an extra ..?* glob for them).
>
> zsh, pdksh (and derivatives, actually derivatives of the Forsyth
> shell which pdksh is based on) and fish expansions never
> include "." nor ".." in their glob expansions, so you can use .*
> reliably in those shells.
For completeness, and to get things back on topic for help-bash,
bash includes a shopt named "dotglob" which makes * match files
beginning with dot. (Not that I'd recommend that solution in this
particular case. chmod -R user:group directoryname is what I would
use, with no globs at all.)