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 10-07-2013, 01:21 PM   #1
Registered: May 2007
Posts: 414

Rep: Reputation: 19
How to build regex for find command with OR

I would like to run one find command and find all files with .pdf or .doc file. I can get it to return them individually but I can't do it in one command. Can someone help me please?

Here is what I have:
$ find . -iregex ".*\.pdf"
$ find . -iregex ".*\.doc"
Both those commands work but how do I get them into one, and add others (e.g. .txt, .chm, etc)?
Old 10-07-2013, 01:29 PM   #2
Senior Member
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,495

Rep: Reputation: 687Reputation: 687Reputation: 687Reputation: 687Reputation: 687Reputation: 687
add an -o

find . -iregex ".*\.pdf" -o -iregex ".*\.doc"
man find

for details


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
C++ find or regex grob115 Programming 2 08-27-2012 11:33 AM
[SOLVED] differences between shell regex and php regex and perl regex and javascript and mysql golden_boy615 Linux - General 2 04-19-2011 01:10 AM
Perl to find regex and print following 5 lines after regex casperdaghost Linux - Newbie 3 08-29-2010 08:08 PM
[SOLVED] 'find' command regex to exclude hidden files? arashi256 Linux - Newbie 3 06-28-2010 08:53 AM
make can't find build command DrRobMD Linux - Newbie 3 04-10-2009 03:08 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:23 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