1

I have a bunch of directories with numerical names, betwen 1 and 1,500 and I wanted to use the find command to find only these that are in range of 1,250 and 1,500, this regular expression should do that: [1][2-5][0-9][0-9] so Itried this command:

find . -regextype sed -regex "[1][2-5][0-9][0-9]"

But find finds nothing, am I doing something wrong?

1 Answer 1

1

From man 1 find [emphasis mine]:

-regex pattern
File name matches regular expression pattern. This is a match on the whole path, not a search. For example, to match a file named ./fubar3, you can use the regular expression .*bar. or .*b.*3, but not f.*r3.

So this will find something:

find . -regextype sed -regex ".*/1[2-5][0-9][0-9]"

Note [1][2-5][0-9][0-9] you used covers the range 1200-1599. [1] can be just 1 as in my example.

You must log in to answer this question.

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