I have been trying to create a find command string that will find all files that end with a number 1-99 but exclude all others.
e.g. I want to find myfile1 myfile99 but not myfile456 and not myfilebackup
The regex I'm thinking of is myfile[1-9]{1,2}
but I can't get this to work with find.
find . -regex '.*myfile[0-9]{1,2}'
OR
find . -iname 'myfile[0-9]{1,2}'
From what I can see it's the {1,2}
part that is not working.
(by the way can you use -name -regex
interchangably?)
Any help appreciated.
-iname
(and-name
) use globs, which do not have this syntax.