Recursively find files with a specific extension

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 !


我的偏好:

find . -name '*.jpg' -o -name '*.png' -print | grep Robert


Using find 's -regex argument:

find . -regex '.*/Robert.(h|cpp)$'

Or just using -name :

find . -name 'Robert.*' -a ( -name '*.cpp' -o -name '*.h' )

This q/a shows how to use find with regular expression: How to use regex with find command?

Pattern could be something like

'^Robert.(h|cgg)$'
链接地址: http://www.djcxy.com/p/78008.html

上一篇: 如何在VIM的大型项目中导航

下一篇: 递归地查找具有特定扩展名的文件