Search code examples
unixls

UNIX 'ls' command exclude wildcard


I have files a1 a2 a3 b1 b2 b3 and I need to exclude a2 and b2 from the list using ls command only.


Solution

  • Try this:

    $ ls [a-b][13]
    a1  a3  b1  b3
    

    Or

    $ shopt -s extglob
    $ ls !(*2)
    a1  a3  b1  b3