LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 07-14-2005, 11:46 AM   #1
nifflerX
Member
 
Registered: Dec 2003
Distribution: RedHat 8.0, 7.1 and Enterprise WS 3,4
Posts: 94

Rep: Reputation: 16
Find command using 2 search conditions


Hi,

I'm trying to do find command that returns the file name if either of two conditions are met. I'm trying to find files that either being with P and end with 7, so they are of the format P*7, or end with BRIK. I've used find

find / -name 'P*7' and find / -name '*BRIK'

but is there a way to combine the two, so I only have to search through / once? So I would run this and any files with a name P*7 or *BRIK would be printed to the screen. Thanks very much.


-NifflerX
 
Old 07-14-2005, 11:52 AM   #2
barghota
Member
 
Registered: Jul 2003
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Debian, FreeBSD
Posts: 94

Rep: Reputation: 38
u could update ur system database filenames using
# updatedb
then search for what u want, simply by
$ locate BRIK
$ locate P*7


I wish this could help
 
Old 07-14-2005, 12:06 PM   #3
nifflerX
Member
 
Registered: Dec 2003
Distribution: RedHat 8.0, 7.1 and Enterprise WS 3,4
Posts: 94

Original Poster
Rep: Reputation: 16
Hi,

I tried that and it sorta worked. The problem is locate only looked at my local drive, and the directory I need to search is actually a NFS share that I've mounted. Although it was much faster than find. Is the only way to do this to use the find command twice and search the directory twice? Thanks very much.

-NifflerX
 
Old 07-14-2005, 12:11 PM   #4
barghota
Member
 
Registered: Jul 2003
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Debian, FreeBSD
Posts: 94

Rep: Reputation: 38
forgot to mention that $ locate doesn't work with me with FAT32 mounted partition
 
Old 07-14-2005, 02:02 PM   #5
hfawzy
Member
 
Registered: Aug 2002
Location: Egypt
Distribution: Debian Sarge, Slackware 10.0
Posts: 163

Rep: Reputation: 30
Not sure if this is the best way to do it, but you can try this:
Code:
find / -regex '.*[BRIK|P*7]'
Cheers.

Last edited by hfawzy; 07-14-2005 at 02:05 PM.
 
Old 07-14-2005, 03:48 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,950
Blog Entries: 11

Rep: Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860
or
find / -name 'P*7' -o -name '*BRIK'
 
Old 07-15-2005, 02:18 AM   #7
katsal
LQ Newbie
 
Registered: Aug 2003
Location: Australia
Distribution: Red Hat Linux
Posts: 7

Rep: Reputation: 0
Re: Find command using 2 search conditions

Quote:
Originally posted by nifflerX
Hi,

I'm trying to do find command that returns the file name if either of two conditions are met. I'm trying to find files that either being with P and end with 7, so they are of the format P*7, or end with BRIK. I've used find

find / -name 'P*7' and find / -name '*BRIK'

but is there a way to combine the two, so I only have to search through / once? So I would run this and any files with a name P*7 or *BRIK would be printed to the screen. Thanks very much.


-NifflerX
Hi NifflerX

This can be done using the FIND command.

Try the following to see if it produces the results that you want.
The below example assumes that the items you are searching for are FILES and not DIRECTORIES.

find . -type f \( -name "P*7" -o -name "*BRIK" \)

Thanks.


My appologies, this solution has already been provided in the previous post. - My bad :-(

Last edited by katsal; 07-15-2005 at 02:19 AM.
 
Old 07-15-2005, 10:22 AM   #8
nifflerX
Member
 
Registered: Dec 2003
Distribution: RedHat 8.0, 7.1 and Enterprise WS 3,4
Posts: 94

Original Poster
Rep: Reputation: 16
Hi,

Thank you so much.

find / -name 'P*7' -o -name '*BRIK'

Worked perfectly. Thanks again!

-NifflerX
 
Old 07-15-2005, 01:37 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,950
Blog Entries: 11

Rep: Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860
Most welcome :}


Cheers,
Tink
 
  


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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
command to search ekdya Linux - Newbie 3 11-12-2005 09:46 AM
pattern search through find command. abhi Linux - Newbie 2 04-11-2005 10:31 AM
Search doesn't find everything it should gargamel LQ Suggestions & Feedback 2 02-18-2005 03:16 PM
search my harddisk - which command ??? merlin23 Linux - Newbie 5 12-14-2004 11:46 AM
Expect test conditions jnusa Programming 0 08-18-2004 04:32 AM


All times are GMT -5. The time now is 07:55 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration