Including dot files, but excluding dot and dot-dot

Note that .bashrc was not included in our example output. We might try to include it by prefixing a second glob with .  but this also includes the . and .. implied entires, referring to the current and parent directory. That could be a disaster if we were going to run rm -r:

$ printf '%s\n' * .*
april
august
october
september
.
..
.bashrc

We will almost never actually want this behavior. One POSIX-compatible way of working around it is using character globbing to exclude . and .. specifically, by requiring a second character that is not a dot:

$ printf '%s\n' * .[!.]*
april
august
october
september
.bashrc

But this would exclude a file named ..bashrc with two leading dots, which  while unconventional  is still a valid filename. How frustrating! Bash offers an option to deal with this called dotglob, which includes dot files in glob expansion for *, but excludes the . and .. implied entries:

$ shopt -s dotglob
$ printf '%s\n' *
.bashrc
april
august
october
september