So I\'ve got the following files in the tmp directory:
file.0
file.1
file.t9
file.22
file.4444
if I wanted to list only the files that
Another variant for filtering files of a specific extension is to use the find
command with a set of predicates:
find tmp/ -type f -iregex '^.*\.[0-9]+$'
The -type
predicate matches only files and the -iregex
matches names that end with one or more digits - ignoring case of the name. If you want to filter files that begin with file
you would use the following instead:
find tmp/ -type f -iregex '^.*/file\.[0-9]+$'
And finally, if you don't want the whole path displayed for each resulting file, use the following:
find tmp/ -type f -iregex '^.*/file\.[0-9]+$' -printf "%f\n"