The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Find command uisng -prune or -only 2reperry UNIX for Advanced & Expert Users 7 02-22-2008 03:55 PM
find command with prune help venu_nbk UNIX for Dummies Questions & Answers 2 05-28-2007 06:25 AM
Find command with prune and exec options Sebarry UNIX for Dummies Questions & Answers 2 06-19-2006 04:07 AM
Find command with prune and exec Sebarry UNIX for Advanced & Expert Users 1 06-18-2006 01:43 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-07-2002
FuzzySlippers FuzzySlippers is offline
Registered User
  
 

Join Date: Nov 2002
Location: Calgary, Alberta, Canada
Posts: 2
Angry Use -prune with find command on AIX

I am trying to get a list of top level directories below the search path but I don't want to descend subdirectories. The find command listed below returns me the list I want but it also returns subdirectories. I can't seem to get the -prune option to work the way I want. How would I modify the following find command?

find ../users -type d \( -name "e[0-9]*" -o -name "users/cnt[0-9]*" \)
../users/cnt4071
../users/e5034071
../users/e0905759
../users/home.archive/e0279813 <-- I don't want to see this one
  #2 (permalink)  
Old 11-07-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Try this:
find ../users \( ! -name users -prune \) -name 'e[0-9]*' -o -name 'cnt[0-9]*'
  #3 (permalink)  
Old 11-07-2002
FuzzySlippers FuzzySlippers is offline
Registered User
  
 

Join Date: Nov 2002
Location: Calgary, Alberta, Canada
Posts: 2
Smile

That worked. Thanks.
  #4 (permalink)  
Old 11-07-2002
Vishnu Vishnu is offline
Registered User
  
 

Join Date: Aug 2002
Location: Marlboro, MA
Posts: 114
That was cool!

As always Perderabo's answers are a real treat!!

BTW I found this site which contains info related to the trick Perderabo had just done...

http://www.uni-ulm.de/~s_smasch/various/find/

great explanation...

Cheers!
Vishnu.
  #5 (permalink)  
Old 11-07-2002
yls177
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
find ../users \( ! -name users -prune \) -name 'e[0-9]*' -o -name 'cnt[0-9]*'


../users -> search in /users.

\( ! -name users -prune \) -> list directories in the level of /users/thislevel.

-name 'e[0-9]*' -> list the single directory level which matches the search criteria

-0 -> the or syntax...

-name 'cnt[0-90*' -> also if matches this.....


is the above understanding correct?
  #6 (permalink)  
Old 11-08-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Yes, but I would phrase it:
\( ! -name users -prune \) -> unless a directory is named "users" do not show its contents.

This reveals the weakness of this approach: it won't work well if we have a:
/users/users/files
Sponsored Links
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 09:07 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