The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can I know find syntax to find given date files bache_gowda Shell Programming and Scripting 3 03-26-2008 02:37 AM
making a recursive find more useful.. spanish_tony UNIX for Dummies Questions & Answers 3 03-14-2007 01:48 AM
find file with date and recursive search for a text rosh0623 UNIX for Advanced & Expert Users 10 08-16-2006 11:27 AM
awk syntax question hcclnoodles Shell Programming and Scripting 2 10-28-2004 09:45 AM
Performing a non-recursive find in Unix christallott UNIX for Advanced & Expert Users 3 09-06-2002 06:13 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-18-2005
Registered User
 

Join Date: Feb 2005
Posts: 11
Question: non-recursive find syntax

Hello, I am trying to search a directory for all files matching "G*" without looking in sub-directories "success" and "error". I've searched this forum and found the following syntax, but can't make it work:

find . \( ! -name success -prune -name error -prune \) -type f -name "G*"

Have consulted the man pages for find, experimenting with -depth but no luck. Please let me know what I'm doing wrong.

Thanks,
alexkav
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-18-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,454
find . \( -name success -prune \) -o \( -name error -prune \) -o -name "G*" -print
Reply With Quote
  #3 (permalink)  
Old 02-18-2005
Registered User
 

Join Date: Feb 2005
Posts: 11
Perfect. Thank you!
Reply With Quote
  #4 (permalink)  
Old 02-21-2005
Registered User
 

Join Date: Feb 2005
Posts: 11
help again

Hello agian, is it possible to adjust the "find" command to only find files beginning with "G" and followed by numbers?

For example:

good: G102030
bad: GFI_UPLOAD.log

Thanks,
alexkav
Reply With Quote
  #5 (permalink)  
Old 02-21-2005
Registered User
 

Join Date: Feb 2005
Posts: 11
Ok, here's using grep:

find . \( -name success -prune \) -o \( -name error -prune \) -o -name "G*" -print) | grep '[0-9]\{6\}'

Thanks,
alexkav
Reply With Quote
  #6 (permalink)  
Old 03-10-2005
milhan's Avatar
Registered User
 

Join Date: Oct 2002
Location: /home
Posts: 121
what if i don't know what subdirectories there are?

Quote:
Originally Posted by Perderabo
find . \( -name success -prune \) -o \( -name error -prune \) -o -name "G*" -print
what if there are a lot of subdirectories, or there are subdirectories under subdirectories(like a tree), that is, I shouldn't be specifying what subdirectories not to descend. Isn't there a way to tell find command to search for file only in the specified directory(but do not descend any subdirectory) ?
Reply With Quote
  #7 (permalink)  
Old 03-10-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,454
Look in the faq section for the answer.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0