user000001
user000001

Reputation: 33357

Why does "echo [a-z]" print "b t"?

What the title says. In bash, when I do:

$ echo [a-z]
b t

What does b t mean? Is there a special meaning for the [ ] operators in this context?

Upvotes: 1

Views: 708

Answers (1)

chepner
chepner

Reputation: 531718

The [a-z] is a pattern that will match any file(s) whose name consists of a single letter. In your case, the current directory has two files named b and t. If there are no matching files, the pattern is treated as literal text, which is why others will see [a-z] printed.

Upvotes: 6

Related Questions