LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-08-2009, 01:36 PM   #1
n179911
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


Hi,

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, 01:45 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
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.

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



Cheers,
Tink

Last edited by Tinkster; 07-08-2009 at 01:47 PM.
 
Old 07-08-2009, 01:52 PM   #3
pixellany
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, 02:14 PM   #4
lemon09
Member
 
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´
 
  


Reply


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 02:50 AM
Shell script to build a list of karaoke music files sorted by artist and title! imix40 Linux - Newbie 4 08-13-2008 08:10 PM
Find files with different extensions cdog Linux - Software 2 03-09-2007 04:38 PM
Which is the kernel build directory? I Can't find kernel build files crabsody Debian 7 01-09-2007 05:48 AM
using bash find command to list *.h and *.cpp wgillett Linux - Software 3 12-15-2005 12:55 PM


All times are GMT -5. The time now is 01:02 PM.

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