find -regex not recognizing curly braces

Must be a bug or something. Whether I escape them or not, it will not work. No matter what I set the minimum and maximum to nothing gets caught. For instance:

find / -regex "/.{0, 50}." -maxdepth 1 or find / -regex "/.\{0, 50\}." -maxdepth 1 should pretty much catch everything residing within the filesystem root directory, but in either case it finds nothing.

How to work around this?

Try adding the regex type option:

find /  -regextype  posix-egrep -regex "/.{0,50}.*" -maxdepth 1

According to the man page on my system (SuSE) the default is emacs. I'm not sure how emacs treats this syntax, but it seems not to be what you want.

The man page indicates that it must appear before the -regex option on the command line.

---------- Post updated at 15:17 ---------- Previous update was at 15:14 ----------

I also noticed when I cut/pasted your command that you have a space between the comma and the 50 which might cause a problem. I'd remove the space such that it is {0,50}

1 Like

The find does not have this option, looks like I need a later version...

That's too bad. I'm not sure what your options are for updating tools, but using the AT&T Labs-Research AST tool set might be an easy option. It is pretty easy to download and build, and it's version of find supports the regex option as you expected without the type qualification.

If you are interested, the page with the information and download links is here:
software download selections

That's no problem I'll just download the newest version (4.4.2) without replacing the one that everyone else uses, thanks.