ducin
ducin

Reputation: 26437

find files using regex with exact digits number

I'm trying to find all files on linux that would match files like these:

frontend_prod_20100112.log
frontend_prod_20110101.log
frontend_prod_20120101.log
frontend_prod_20121231.log

the only variable here is 8 digits inside (exactly 8). I'm trying to run:

find . -regex ".*frontend_prod_[0-9]{8}\.log"

or

find . -regex ".*frontend_prod_(\d){8}\.log"

but it doesn't work.

Thanks for any help.

Upvotes: 3

Views: 2296

Answers (1)

Tim Pietzcker
Tim Pietzcker

Reputation: 336128

Since this is POSIX, you need a slightly different syntax:

find . -regex ".*frontend_prod_[0-9]\{8\}\.log"

Upvotes: 3

Related Questions