I have files a1 a2 a3 b1 b2 b3 and I need to exclude a2 and b2 from the list using ls command only.
ls
Try this:
$ ls [a-b][13] a1 a3 b1 b3
Or
$ shopt -s extglob $ ls !(*2) a1 a3 b1 b3