LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 03-02-2004, 09:42 AM   #1
odious1
Member
 
Registered: Jun 2003
Location: Virginia, USA
Distribution: Slackware
Posts: 252

Rep: Reputation: 30
probably a simple shell question


I am trying to use find to search for more than one pattern at a time. I want to be able to pass it as and arguemnt but cant find the proper syntax if there is a way to do it.

for example can it exclude .bkf and .$$$ somehow.

I know it can find /* \! -name *.bkf but can I pass a string argument and exclude both or even more somehow?

Thanks
 
Old 03-02-2004, 01:56 PM   #2
rokka
Member
 
Registered: Feb 2004
Location: .se
Distribution: Ubuntu, debian
Posts: 124

Rep: Reputation: 15
Not sure I understand what you want but if you are familiar with regexps piping to grep might solve your problem.

find . | grep -E 'apattern|anotherpattern'
 
Old 03-02-2004, 08:10 PM   #3
odious1
Member
 
Registered: Jun 2003
Location: Virginia, USA
Distribution: Slackware
Posts: 252

Original Poster
Rep: Reputation: 30
thanks, i will do some reading on that. i am redirecting the stout of find to a list that is read by tar. i think i need to keep my end of line null character intact for tar, not entirely sure. please keep the ideas comming. ideally i could do something with find such as find /mnt/public -mtime 8 \! -name [arg1,arg2] > tarlist but i do not know how if it is even possible.
 
Old 03-02-2004, 08:26 PM   #4
eccles23
Member
 
Registered: Jun 2003
Location: Australia
Distribution: Gentoo/kernel 2.6.2
Posts: 45

Rep: Reputation: 15
locate blah | grep -v '.bkf' | grep -v '.$$$'

this will filter out all results that contain .bkf and .$$$

and if you want to make sure it only does it to those results that actually end in those characters, then use ".bkf$" hmmm... not sure how you'd do it with the ones with $ in them though... perhaps ".$$$/$" ? but don't quote me hehe or perhaps '.\$\$\$$' ?
 
Old 03-02-2004, 08:38 PM   #5
odious1
Member
 
Registered: Jun 2003
Location: Virginia, USA
Distribution: Slackware
Posts: 252

Original Poster
Rep: Reputation: 30
thanks, that might be my answer
 
Old 03-02-2004, 09:26 PM   #6
tearinox
Member
 
Registered: Aug 2003
Location: you dont want to know
Distribution: Gentoo 2004.2, Slackware 10, Windows XP, Windows 2003 Server
Posts: 348

Rep: Reputation: 30
cd /
ls -R > file.txt
grep [pattern] file.txt

kind of crude way, but you could then make a little bash script out of this and instantly re-search over and over quickly. Then delete the file at the end.
 
Old 03-03-2004, 10:06 AM   #7
dford
Member
 
Registered: May 2003
Location: Kansas
Distribution: RH 9, OpenBSD, FreeBSD
Posts: 60

Rep: Reputation: 19
Quote:
Originally posted by eccles23
locate blah | grep -v '.bkf' | grep -v '.$$$'

this will filter out all results that contain .bkf and .$$$

and if you want to make sure it only does it to those results that actually end in those characters, then use ".bkf$" hmmm... not sure how you'd do it with the ones with $ in them though... perhaps ".$$$/$" ? but don't quote me hehe or perhaps '.\$\$\$$' ?
The latter match for $$$ is correct: '.\$\$\$' will match any character followed by three dollar signs. If you want to only match a single period followed by three dollar signs, include a backslash before the period: '\.\$\$\$'

A shorter way to do this is to use egrep. Suppose I want a list files in the current directory excluding '.bkf' and '.$$$' files:
Code:
 ls -1 | egrep -v '(\.bkf$|\.\$\$\$$)'
Note: I am only excluding files that end in '.bkf' or '.$$$'. If that pattern occurs elsewhere in the file name, it will not be excluded.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Shell Scripting Question hellomynameisphil Programming 2 08-27-2005 03:41 AM
simple c-shell question mathias1979 Programming 1 06-27-2005 04:51 PM
A shell command simple question the_rhino Linux - Newbie 6 09-13-2004 01:57 PM
simple question on shell programming stupid_guy Programming 5 03-10-2004 02:07 PM
simple shell script question. strifel Programming 7 09-13-2003 01:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:46 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
Open Source Consulting | Domain Registration