Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recursively find files with a specific extension

Tags:

linux

bash

I'm trying to find files with specific extensions. For example, I want to find all .pdf and .jpg files that's named Robert

I know I can do this command

$ find . -name '*.h' -o -name '*.cpp' 

but I need to specify the name of the file itself besides the extensions. I just want to see if there's a possible way to avoid writing the file name again and over again Thank you !

like image 329
A1X Avatar asked Sep 05 '14 20:09

A1X


People also ask

How do I search for all files with specific extensions?

For finding a specific file type, simply use the 'type:' command, followed by the file extension. For example, you can find . docx files by searching 'type: . docx'.

What command can we use to recursively find all files with an INI extension?

Using Glob() function to find files recursively We can use the function glob.


1 Answers

My preference:

find . -name '*.jpg' -o -name '*.png' -print | grep Robert 
like image 137
FoggyDay Avatar answered Sep 28 '22 14:09

FoggyDay