0

I would like to list multiple files in a range. My files structure is PR181111???.s01 or PR189999???.s01 so the variable I have to use are 1111 and 9999. This can be an operation to do several times a day with new files, hence is not a single-time listing.

In a script I tried to use (just an example)

ls *[0987-0991]*.s01

my output

PR180985026.s01  PR180987023.s01  PR180991022.s01
PR180987021.s01  PR180987025.s01  PR180991024.s01

Could someone explain me why I get the first file (PR180985026.s01)?

The first file is outside the range I specified, therefore I am doing something wrong.

2
  • That's not how [...] brackets work - they are sets (or collation sequences) of single characters Aug 19, 2018 at 17:05
  • So how should I do?
    – esse_emme
    Aug 19, 2018 at 17:07

1 Answer 1

0

I try to list only file in range PR180987???.s01-PR180991???.s01

That can be done with for instance:

ls PR18{0987,0988,0989,0990,0991}???.s01
ls PR18[09]{87,88,89,90,91}???.s01
ls PR18[09]{87-91}???.s01
5
  • if I have more files in the range is not very useful....
    – esse_emme
    Aug 19, 2018 at 17:17
  • @esse_emme your fault not mine. If you do not specify you do not get the answer you want. Then again: { and } are for ranges Feel free to adjust my answer to fit within what you want. The chars in between { } are also best done within a script with a for next loop. Saves typing.
    – Rinzwind
    Aug 19, 2018 at 17:19
  • I try to list files in ranges. The could be between PR181111???.s01 and PR189999???.s01. I I start typing all of them one life is not enough...
    – esse_emme
    Aug 19, 2018 at 17:21
  • @esse_emme correct but again that is NOT what you asked. You asked about " between 0987 and 0991".
    – Rinzwind
    Aug 19, 2018 at 17:22
  • OK, but for testing I start using a limited range, otherwise....
    – esse_emme
    Aug 19, 2018 at 17:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .