Reputation: 329
as the document describes,[set]
in Bash can match any character in set
,
in the following , I hava 3 dirs called a,b,c in current directory:
$ ls
a b c
$ ls [abd] # just as expected,show dirs a and b
a:
b:
$ ls [bd] # expecting show dir b but noting matched
$ ls [ad] # expecting show dir a but noting matched
can someone explain this to me?thanks!
Upvotes: 2
Views: 74
Reputation: 785581
This is correct behavior.
ls [bd]
Prints files inside the directory b
and that is empty.
To test further you can do:
touch b/foo
ls [bd]
Which will give output
foo
PS: However in your first command when you do ls [abc]
there are more than one matching directories in current path a
and b
hence you get the output as shown in in your question.
Upvotes: 4