How to list some files, in a specific range

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

1 Answer

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like