Re: [Help-bash] Glob star pattern does not match files beginning with a
From:
Michael Convey
Subject:
Re: [Help-bash] Glob star pattern does not match files beginning with a period
Date:
Mon, 13 Jul 2015 14:50:08 -0700
On Mon, Jul 13, 2015 at 11:57 AM, David Niklas <address@hidden> wrote:
> ls *
> Documents
> tmp
> rtorrent-session
>
> I'm using bash version 4.3.39.
> I want * to match _everything_ but "." and ".." .
>
> Thanks, David
>
>
​According to the bash reference manual:
When a pattern is used for filename expansion, the character ‘.’ at the
start of a filename or immediately following a slash must be matched
explicitly, unless the shell optiondotglob is set.
Source: http://www.gnu.org/software/bash/manual/bash.html#Filename-Expansion
Therefore, you need two arguments to the ls command to accomplish what you
are trying to do, as follows:
ls -d * .[!.]?*​
The first argument * matches all regular files. The second argument .[!.]?*
matches all hidden files by expanding into every filename that begins with
a period, does not include a second period, contains at least one
additional character, and may be followed by any other characters.
​Your original command will work if you set the dotglob​ option via "shopt
-s dotglob".