I have a directory with the following files:
root.o
root.type1
root.type2
root.type1.c
root.type2.c
root.type1.c.pa0
root.type2.c.pa0
root.type2.c.pa1
root.type2.c.pa2
root.type2.c.pa3
....
root.type2.c.pa100
root.type2.c.pa0.out
root.type2.c.pa1.out
root.type2.c.pa2.out
root.type2.c.pa3.out
...
root.type2.c.pa100.out
I would like to list the files that begin with root.type2.c.pa.
and end with numbers, excluding the files ending with .out
. In other words, I want to list this chunk :
root.type2.c.pa0
root.type2.c.pa1
root.type2.c.pa2
root.type2.c.pa3
....
root.type2.c.pa100
Writing ls root.type2.c.pa?
, ls root.type2.c.pa??
, and ls root.type2.c.pa???
would do the job.
Is their a simple way to list the chunk without knowing how many numbers there are at the end of the desired files ? In the example above, we have at most 3 numbers. In practice, I may have 1, 2, 3, 4, or 5 numbers.
shopt -s extglob
ls root.type2.c.pa+([0-9])