find files their name is smaller or greater than a given parameter
- by Tzury Bar Yochay
Say that in a given directory I got
tzury@x200:~/Desktop/sandbox$ ls -l
total 20
drwxr-xr-x 2 tzury tzury 4096 2011-03-09 10:19 N00.P000
drwxr-xr-x 2 tzury tzury 4096 2011-03-09 10:19 N00.P001
drwxr-xr-x 2 tzury tzury 4096 2011-03-09 10:19 N00.P002
drwxr-xr-x 2 tzury tzury 4096 2011-03-09 10:19 N00.P003
drwxr-xr-x 2 tzury tzury 4096 2011-03-09 10:19 N00.P004
drwxr-xr-x 2 tzury tzury 4096 2011-03-09 10:19 N01.P000
drwxr-xr-x 2 tzury tzury 4096 2011-03-09 10:19 N01.P001
drwxr-xr-x 2 tzury tzury 4096 2011-03-09 10:19 N01.P002
I seek for a bash way to grab the list of files which their name is either grater or smaller than a given parameter, for instance:
$ my_finder lt N00.P003
shall return N00.P000, N00.P001 and N00.P002
$ my_finder gt N00.P003
shall return N00.P004, N01.P000, N01.P001 and N01.P002
I was thinking of iterating over for name in $(ls) and while $name != $2 but believe there are more elegant way of doing so