I'm having a lot of trouble getting find
to work with regex flags. Im using egrep
on its own to find a date pattern in a file, like this:
egrep '[0-9]{4}-[0-9]{2}-[0-9]{2}'
which will return dates formatted as CCYY-MM-DD just fine. I'm trying to use this same pattern with find
. I have tried:
find . -regextype egrep -regex "[0-9]{4}-[0-9]{2}-[0-9]{2}"
find . -type f -regex "[0-9]{4}-[0-9]{2}-[0-9]{2}"
Tried to backslash the curly brackets...
find . -type f -regextype egrep -regex "[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}"
All of these don't seem to return anything. I get no error messages, no output... I have even tried to redirect the ouput to a file, but nothing...
It's hard to find good resources on using find
with regex.
If any one could help, I would greatly appreciate it. I'm not opposed to any of the types of regex find
supports though I like egrep
because of the -o
flag for returning only the matches, NOT the entire line. But really I just need find
to find all files in a directory that have a match of pattern above in the file name.