Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unix: Find files with a number as the extension

Tags:

find

unix

I'm trying to do a search on a directory to find just the files that have a number as the extension (i.e. file.12345, file2.23415, file3.85472). Is there any way to do this in unix. I have been trying to find a way using the find command and wildcards, such as:

find . -name \*.#####

where the # is a wildcard for a single number or even a string of numbers, however, there doesn't seem to be anything like this that I can find, so are there any other suggestions. I am a fairly basic user of unix, but anything would help. Thank you.

like image 992
jr2114 Avatar asked Oct 29 '25 14:10

jr2114


2 Answers

Try using find . -print | grep -E '\.[0-9]+$'.

like image 183
mark4o Avatar answered Oct 31 '25 11:10

mark4o


How about something like this?

find . -regex '.+\.[0-9]+'
like image 20
ziesemer Avatar answered Oct 31 '25 13:10

ziesemer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!