Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying the following globs in a bash shell:

$ ls -d .*
.  ..  .a  .ab
$ ls .a*
.a  .ab
$ ls .[!.]*
.a  .ab
$ ls .[!.]?*

Shouldn't the last expression mean "a dot followed by exactly one non-dot followed by zero or more characters"? Why does it fail to match .a?

share|improve this question
up vote 5 down vote accepted

You are mistaken. It means "a dot followed by exactly one non-dot followed by one character followed by zero or more characters". .a does not have enough characters to match it.

But really, just set dotglob.

share|improve this answer
Thanks, I thought the question mark referred to the non-dot. No need to set dotglob, just playing around. :) – 3lectrologos Apr 9 '12 at 16:43
If you were using regular expressions, then "[^.]?" would mean either a single non-dot character, or no characters. But in shell globbing syntax "?" matches any single character (basically, "?" in shell globbing is equivalent to "." in regular expressions). – MadScientist Apr 9 '12 at 23:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.