Reputation: 195
I have files a1 a2 a3 b1 b2 b3 and I need to exclude a2 and b2 from the list using ls
command only.
Upvotes: 11
Views: 27699
Reputation: 161674
Try this:
$ ls [a-b][13]
a1 a3 b1 b3
Or
$ shopt -s extglob
$ ls !(*2)
a1 a3 b1 b3
Upvotes: 7
Reputation: 7807
Try with ls and grep
ls -1 | grep -viw "a2\|b2"
Pay attention after ls a put 1 (the number one) and not the letter "l". Sometimes the font make them confusing.
Upvotes: 2