Regex in find command. Simple search using alternation doesn't seem to work

22 Views Asked by At

I think I'm fairly well-versed in regex in tcl, but in the shell, I'm very new. It seems the syntax is slightly different.

I'm simply trying to recursively find all files that have multib or multi_b in the name.

find . -type f -regex ".*multi(b|_b).*"

does not work. Even getting rid of '|_b' in the expression doesn't find a match. It seems I have to escape parentheses in order to group, opposite of how it's done in tcl.

find . -type f -regex ".*multi\(b\).*"

matches. However, if I add the OR character, I get no matches.

    find . -type f -regex ".*multi\(b|_b\).*"

No match. Is there something obvious I am missing here?

1

There are 1 best solutions below

1
jktstance On

anubhava's suggestion was the problem. Using -regextype egrep worked. I wonder why that mode isn't the default, though.