I am hoping someone can help me. I am trying to use glob to find a filename. I want to find a fil开发者_运维百科e name that contains a 2 OR a 4 as the fifth character in the file name. For example, I want to write a glob that would find these file names:
00002.txt
00004.txt
12002.txt
I understand that I could use glob to find these files using a series such as:
ls ????[2-4]*
However, the above glob would also match files that had a 3 as the fifth character. Does anyone know how to glob for only files that contain a 2 OR 4 as the fifth character? Thanks very much for your time!
Using [24]
will allow just 2 or 4, instead of the range [2-4]
, giving you:
ls ????[24]*
精彩评论