LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-21-2004, 08:07 PM   #1
chovy
Member
 
Registered: Dec 2004
Location: Capitola, CA
Distribution: Debian
Posts: 52

Rep: Reputation: 15
help with "find" command


I want to both require and prune two different directories in my find command:

find . -path "*/logs/*"

and -prune "./snapshots" at the same time, any idea how to do this?

I can't seem to do both at the same time.
 
Old 12-21-2004, 08:45 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
What are you trying to achieve, and how are you
trying to do this? Give's the complete syntax and
a few bits and pieces of what the directory structure
looks like, and what you want to get rid of.



Cheers,
Tink
 
Old 12-22-2004, 10:47 AM   #3
chovy
Member
 
Registered: Dec 2004
Location: Capitola, CA
Distribution: Debian
Posts: 52

Original Poster
Rep: Reputation: 15
Like I said, I want to force one directory, and weed out another in the same find command.


I am trying to accomplish something to this effect:

find . -path "*/logs/*" -maxdepth 4 -path "./snapshots/*" -prune

where it forces the path to have "logs" and skips "snapshots"...the problem being, I have a huge amount of data, and ./snapshots contains duplicates snapshots of the data every hour. So I don't want to traverse that directory, since it contains 5 times the amount of the original file tree.

Make sense? (the above doesn't work)

Last edited by chovy; 12-22-2004 at 10:54 AM.
 
Old 12-22-2004, 11:31 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Hmmmm ... if the "*/logs/*" is to force one directory,
why don't you just
find ./logs -maxdepth 4 -a \( -path "./snapshots/*" -prune \)
or something to that effect? Would make it quite clear,
and probably slightly less costly ...


Cheers,
Tink
 
Old 12-22-2004, 11:36 AM   #5
chovy
Member
 
Registered: Dec 2004
Location: Capitola, CA
Distribution: Debian
Posts: 52

Original Poster
Rep: Reputation: 15
Because my directory structure looks like this:

./foo/logs/
./foo2/logs/
./foo3/logs/
./snapshot/hourly/foo/logs, etc. etc.
./snapshot/hourly.1/foo/logs, etc. etc.
./snapshot/hourly.4/foo/logs, etc. etc.


I have 582 "foo" directories, inwhich I want to find all log files. Skipping ./snapshots would make the search faster.
 
Old 12-22-2004, 12:46 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Code:
find . \( -path '*snapshots*' -prune \) -o -path '*logs*' -print
Try that one ...



Cheers,
Tink
 
Old 10-12-2005, 12:05 PM   #7
chovy
Member
 
Registered: Dec 2004
Location: Capitola, CA
Distribution: Debian
Posts: 52

Original Poster
Rep: Reputation: 15
Similar problem...

I can't seem to combine any other find arguments with -prune:


find ./ -path "*.snapshots*" -prune -o print


But when I add -user nobody, it just matches all users.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 07:42 AM
Not able to Run/find "configure" command aaryan72 Linux - Newbie 4 09-10-2005 11:16 AM
Warning on running "find" command satimis Linux From Scratch 1 08-06-2005 11:45 AM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 02:32 PM
Help,I can't find my USB mouse when I run "kudzu" command in RH9. aeolus Red Hat 0 03-27-2004 09:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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