[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Glob star pattern does not match files beginning with a
From: |
Stephane Chazelas |
Subject: |
Re: [Help-bash] Glob star pattern does not match files beginning with a period |
Date: |
Tue, 21 Jul 2015 06:35:12 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
2015-07-15 14:19:49 -0600, Eric Blake:
[...]
> Both of these three-glob approaches can be used to obtain all file names
> that are not '.' or '..':
>
> ls -d * .[!.]* ..?*
>
> or:
>
> ls -d * .??* .[!.]
>
> but you still have to deal with the fact that unless nullglob is
> enabled to eliminate a glob that has no matches, you are then passing
> unexpanded globs to ls that may result in listing a valid file name
> twice
That should be:
ls -d -- * .[!.]* ..?*
Note that that one will not list files twice since those
patterns don't match each other.
> There is no two-glob pattern that can cover all file names except for .
> and .., unless you resort to bash's extended globs (at which point, you
> might as well do it in a single glob that uses alternation).
For completeness, note that setting GLOBIGNORE do a non-empty
string turns dotglob on, so:
GLOBIGNORE=.
ls -d -- *
would work. With GNU ls, you can then (with dotblog) also do:
ls -dU -- *
to avoid the double sorting.
For ls of course, you only need "ls -A" here.
Note that zsh globs have a syntax to turn on those various
options on a per glob basis, which IMO is a much better
approach. I wish bash had something similar:
ls -d -- *(D)
(for dotglob, *(N) for nullglob...)
--
Stephane
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, (continued)
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, Michael Convey, 2015/07/15
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, Greg Wooledge, 2015/07/15
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, Eric Blake, 2015/07/15
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, Michael Convey, 2015/07/15
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, Peter West, 2015/07/16
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, Greg Wooledge, 2015/07/16
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, Eric Blake, 2015/07/16
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, Michael Convey, 2015/07/16
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, Eric Blake, 2015/07/16
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, Greg Wooledge, 2015/07/17
- Re: [Help-bash] Glob star pattern does not match files beginning with a period,
Stephane Chazelas <=
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, Michael Convey, 2015/07/24
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, Greg Wooledge, 2015/07/24
- Re: [Help-bash] Glob star pattern does not match files beginning with a period, Matthew Cengia, 2015/07/24
Re: [Help-bash] Glob star pattern does not match files beginning with a period, Dennis Williamson, 2015/07/13