Excluding directories with find | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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 !!

Excluding directories with find

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-20-2007
x96riley3 x96riley3 is offline
Registered User
 
Join Date: Mar 2006
Last Activity: 20 May 2013, 3:39 PM EDT
Location: Nashville
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Bug Excluding directories with find

How do I exclude directories with the find command on Solaris?


I want to skip the directories /proc and /shared.

find / -nouser -print

This shows me all files and directories that don't have an owner but I need to skip /shared and /proc.

I've been able to get it to work on Linux and HP but not on Solaris. It appears that the -path option doesn't exist on solaris.

Thanks,
-x96
Sponsored Links
    #2  
Old 02-20-2007
sb008 sb008 is offline Forum Advisor  
Registered User
 
Join Date: Jan 2007
Last Activity: 12 January 2013, 3:37 AM EST
Posts: 398
Thanks: 1
Thanked 3 Times in 3 Posts
Quote:
Originally Posted by x96riley3
How do I exclude directories with the find command on Solaris?


I want to skip the directories /proc and /shared.

find / -nouser -print

This shows me all files and directories that don't have an owner but I need to skip /shared and /proc.

I've been able to get it to work on Linux and HP but not on Solaris. It appears that the -path option doesn't exist on solaris.

Thanks,
-x96
'

/proc is easy to exclude


Code:
find / ! -fstype proc -nouser -print

If /shared happens to be an nfs filesystem that 1 is easy as well.


Code:
find / ! -fstype proc -a ! -fstype nfs -nouser -print

If /shared is not an nfs filesystem, but a local filesystem you can use

find <list of all filesystems except /proc and /shared> -mount -nouser -print.
e.g.


Code:
find / /var /opt /tmp -mount -nouser -print

If /shared is not a seperate filesystem but just a directory on a filesystem there is no option as far as I know, except to filter those results out.
Sponsored Links
    #3  
Old 02-20-2007
x96riley3 x96riley3 is offline
Registered User
 
Join Date: Mar 2006
Last Activity: 20 May 2013, 3:39 PM EDT
Location: Nashville
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the info.

/shared is and nfs file system

[root@servername]/var/tmp>df -n | grep shared
/shared/candle : nfs
/shared/ssg : nfs
/shared/spd : nfs
/shared/dsm : nfs
[root@servername]/var/tmp>


When I run your command above:

find / ! -fstype proc -a ! -fstype nfs -nouser -print


I see this output:

find: cannot read dir /shared/candle/lost+found: Permission denied
find: cannot read dir /shared/candle/002/candledev/config/.ConfigData: Permission denied
find: cannot read dir /shared/candle/002/candledev/sol26: Permission denied
find: cannot read dir /shared/candle/00r2/candledev/config/.ConfigData: Permission denied


It appears that even though the perm won't let me, the find command is still NOT skipping /shared.

Thanks,
x96
    #4  
Old 04-08-2009
gipser gipser is offline
Registered User
 
Join Date: Apr 2009
Last Activity: 26 May 2009, 5:28 PM EDT
Location: Switzerland
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
try

find / ! -fstype proc -a -wholename './shared' -prune -o -nouser -print
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Excluding Hidden Directories from being scanned metallica1973 Programming 3 01-13-2012 11:24 AM
List directories and sub directories recursively excluding files pointers UNIX for Dummies Questions & Answers 3 02-23-2011 08:39 PM
cp -r excluding certain directories? sarnobat Shell Programming and Scripting 2 01-13-2009 06:30 PM
excluding directories in tar thumper Shell Programming and Scripting 2 03-29-2006 04:44 PM
excluding directories while using tar uchachra UNIX for Dummies Questions & Answers 2 03-12-2002 01:38 AM



All times are GMT -4. The time now is 04:35 AM.