The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to prune multiple branches with find? siegfried UNIX for Dummies Questions & Answers 1 04-11-2008 04:52 AM
find command with prune help venu_nbk UNIX for Dummies Questions & Answers 2 05-28-2007 07:25 AM
finding files using prune option subodh.sharma Shell Programming and Scripting 1 11-02-2005 11:11 AM
Use -prune with find command on AIX FuzzySlippers UNIX for Dummies Questions & Answers 5 11-08-2002 09:24 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-19-2006
highlt highlt is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 8
find with prune option

Hello-

I'm trying to write a find command that will exclude certain directories to speed up the find and search the rest of the directory structure to list any files that contain the specified values listed in my egrep.

Specifically, I want the command below to search the current directory and all sub-directories EXCEPT for the "log" and "out" directories and give me a list of file names that contain "sun1216, sun1586, sun1153, PRIVIS1, PRIVIS2". I expected the command below to do the trick but it appears to not work.

find . -follow \( -name "log" -o -name "out" \)
-prune | xargs egrep -li "sun1216|sun1586|sun1153|PRIVIS1|PRIVIS2"

Any suggestions on what's wrong?
Any suggestion on using exec versus xargs?

Thanks
  #2 (permalink)  
Old 12-19-2006
highlt highlt is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 8
I apologize, the syntax is:

find . -follow \( -name "log" -o -name "out" \)
-prune -o -print | xargs
egrep -li "sun1216|sun1586|sun1153|PRIVIS1|PRIVIS2"
  #3 (permalink)  
Old 12-19-2006
highlt highlt is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 8
No suggestions?
  #4 (permalink)  
Old 12-19-2006
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
find . -follow \( -name "log" -o -name "out" \) -prune -o -print | egrep -li "sun1216|sun1586|sun1153|PRIVIS1|PRIVIS2"
that is, remove the xargs from your final syntax
  #5 (permalink)  
Old 12-20-2006
highlt highlt is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 8
The command you provided does not appear to work. It returns nothing? I'm currently testing this:

find . -follow -type d \( -name log -o -name out \) -prune -o -type f
-exec egrep -li 'sun1216|sun1586|sun1153|PRIVIS1|PRIVIS2' {} \;
  #6 (permalink)  
Old 12-20-2006
highlt highlt is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 8
Any more suggestions? Thanks for the feedback.
  #7 (permalink)  
Old 12-21-2006
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
Quote:
Originally Posted by highlt
The command you provided does not appear to work. It returns nothing? I'm currently testing this:

find . -follow -type d \( -name log -o -name out \) -prune -o -type f
-exec egrep -li 'sun1216|sun1586|sun1153|PRIVIS1|PRIVIS2' {} \;
That is the wrong command. Try the one I posted.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0