Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-08-2009, 12:36 PM   #1
LQ Newbie
Registered: Jul 2009
Posts: 8

Rep: Reputation: 0
how to use find to build a list of files with *.cpp *.h *.cc *.mm *.java extensions


How can I use find to build a list of files with *.cpp *.h *.cc *.mm *.java extensions?

I tried
find . -name "*.cpp|*.h|*.java|*.cc|*.mm" -print

That prints out nothing.

Thank you.
Old 07-08-2009, 12:45 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
That won't work because shell globbing isn't regex pattern matching.

find . \( -name "*.cpp" -o -name "*.cc"  \) -print
You get the idea.


Last edited by Tinkster; 07-08-2009 at 12:47 PM.
Old 07-08-2009, 12:52 PM   #3
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Take a look at "man find"---especially the -regex option
Old 07-08-2009, 01:14 PM   #4
Registered: Jun 2009
Location: kolkata,India
Distribution: Mandriva,openSuse,Mint,Debian
Posts: 285
Blog Entries: 1

Rep: Reputation: 37
there are other tools too....
´locate´ and ´grep´ are such tools(very powerful)
you can use them along with ´find´


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Not able to read list of files in folder from java sbzenith Linux - Newbie 2 05-26-2009 01:50 AM
Shell script to build a list of karaoke music files sorted by artist and title! imix40 Linux - Newbie 4 08-13-2008 07:10 PM
Find files with different extensions cdog Linux - Software 2 03-09-2007 03:38 PM
Which is the kernel build directory? I Can't find kernel build files crabsody Debian 7 01-09-2007 04:48 AM
using bash find command to list *.h and *.cpp wgillett Linux - Software 3 12-15-2005 11:55 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:51 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration