sharkdp / fd

A simple, fast and user-friendly alternative to 'find'
Apache License 2.0
34.29k stars 816 forks source link

Regexes for file extension #1604

Closed j-lakeman closed 3 months ago

j-lakeman commented 3 months ago

I'd like to find all files with at least one underscore in the file extension. I haven't found any way to achieve this with regexes only. Could the --extension flag allow regexes? E.g. fd --extension '.*_.*'

tavianator commented 3 months ago

fd '\..*_.*' should work

tmccombs commented 3 months ago

Or use the --glob option and do *.*_*

j-lakeman commented 3 months ago

Cheers guys! Both your approaches work, but they also find heaps of “unwanted” files e.g. .gitignore_global or .bak_0.log or Application_Lite_18.1_download.pdf.

tavianator commented 3 months ago

Perhaps fd '[^.].*\.[^.]*_[^.]*$'

j-lakeman commented 3 months ago

That seems to work, thanks!