Grep to fetch exact list

Hi

I have below lists of files

filename-1.0.0.tar.gz
filename-1.0.1.345657676.snapshots.tar.gz

so when I do

grep -o 'filename-[^""]*.tar.gz' | sort | tail -1

then it consider snapshots as a part of it's result.
How can I make sure, that it should only display the results from 'filename_[0-9]*.[0-9]*.[0-9]*.tar.gz' ? not to include any others .

1 Like

How about

grep -o 'filename-[[:digit:].]*.tar.gz' file
filename-1.0.0.tar.gz
2 Likes
ls filename*[0-9].tar.gz
1 Like
grep -E '^filename-([0-9]+\.){3}tar\.gz' file