Using the find
command, I want to see the files in /usr/include
whose name contains at least one number
.
I tried this command :
find /usr/include -type f -regex '.\*[0-9].\*$'
But the number is not always in the name of the file but sometimes in the path. For example /usr/include/linux/netfilter_ipv4/ipt_ah.h
is found.
After that, I tried this command :
find /usr/include -type f -regex '/[^\/]*[0-9][^\/]*$'
But it returns nothing.
How can I resolve this problem?
If you use the -name
test instead of the -regex
test, it will match only the filename, ignoring the preceding directories (see the man page). Note that -name
uses a shell pattern rather than a regex pattern, so the syntax is slightly different. You can use this command to find files which have numbers in the filename:
find /usr/include -type f -name '*[0-9]*'