List only certain files in a directory matching the word BOZO and ending with either '123' or '456'

Geordie picture Geordie · Jun 14, 2011 · Viewed 67.1k times · Source

I'm trying to figure out how to get a list of file names for a file named BOZO but ending with ONLY 123 OR 456.

Files are:

BOZO12389,
BOZOand3
BOZOand456
BOZOand5
BOZOhello123

So the command should only display 'BOZOhello123' and 'BOZOand456'

I can't figure it out. I've tried all forms of LS and GREP that I can think of. The funny thing is, we tried to do it in class for about 10mins and no one could get it (including the instructor).

Answer

dave picture dave · Jun 14, 2011

I did the following and it worked

ls BOZO*456 BOZO*123