1

1)

echo *

Only displays file names having [a-z, A-Z] but does not display files starting with .

For example .bashrc is not covered with shell glob *

2)

echo .* gives the expected output.


In first case, why does the shell glob does not include file names with dot?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
overexchange
  • 1,536

1 Answers1

6

That’s just the way globbing works, by default (in general, not just in shells). As per the glob(7) manpage:

Pathnames

[...]

If a filename starts with a '.', this character must be matched explicitly. (Thus, rm * will not remove .profile, and tar c * will not archive all your files; tar c . is better.)

See also the relevant section of POSIX.

There are shell settings you can use to change this, or globbing modifiers in some shells that you can add to change the behaviour temporarily; see What is the setting in bash for globbing, to control whether * matches dot files for more details.

Stephen Kitt
  • 434,908