|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to find from / but exclude certain folder?
Hi Unix Specialists,I need your advice on how to find all the files from root ( / ) filesystem but exclude those from /export/home (different filesystem) folder. Below are some of the find statements that I have tried without success: Code:
find / -name '/export/home' -prune -o print -ls Code:
find / -type d -name '/export/home' -prune -o -ls find / -type d -name "\/export\/home" -prune -o –ls General searches & man page suggest similar commands but still couldn’t work it out still. I am running on Solaris 10 x86 platform. Your assistance would be much appreciated. Thanks, George |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
I dont get you here, what are you looking for?
If /export/home is a separate filesystem, why are you looking for it then? |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Hi vbe,
I need to search for all the files from / onwards which means that it would also pickup everything on /export /home as well. As a result, I am looking for the right find syntax command to list every single files & folders starting from / (root) filesystem but ignore or bypass /export/home folder which is also a filesystem. One way to do this is to unmount /export/home before running "find / -ls". However, it is not possible to unmount this filesystem due to opened files & database in a production environment. Thanks, George |
|
#4
|
|||
|
|||
|
Do not use -name, use -path (I hope it works in Solaris): Code:
find / -type d -path /export/home -prune -o -ls |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
A workaround for find without -path: Code:
find / -type d -name home -exec test {} = /export/home \; -prune -o -lsThe -name home expression is not required, but it saves work by preventing -exec test ... when it cannot possibly succeed. Regards, Alister Last edited by alister; 06-16-2012 at 05:28 PM.. |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Another way. Work from the mounted filesystem list and ignore /export/home . Code:
#!/bin/ksh
mount | awk '{print $1}' |grep -v "\/export\/home" | sort | while read filesystem
do
find ${filesystem} -xdev -type f -print
doneThe "-type f" is because you mentioned files not directories. The "sort" is because I like things on order ! The "-xdev" confines the "find" to that filesystem, thus avoiding duplicates caused by links. Ps. If you actually wanted to only search the root filesystem, the "-xdev" is a big hint. Last edited by methyl; 06-16-2012 at 06:42 PM.. Reason: mispaste |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Hi All,
Thanks to all 3 respondent to my queries. Below are the out the outcome from your suggestions: Quote:
find: [-H | -L] path-list predicate-list (Solaris does not support -path syntax) Quote:
Quote:
The second suggestion is most useful even though it is much appreciated for all your inputs. Thanks, George |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Solved] Using Find with an exclude/exclude file | metallica1973 | Ubuntu | 2 | 10-23-2011 10:07 AM |
| Find command with exclude | db2dbac | Shell Programming and Scripting | 1 | 05-31-2011 07:35 PM |
| Exclude a directory in 'find' | mutex1 | Shell Programming and Scripting | 1 | 12-19-2010 04:50 PM |
| Find all text files in folder and then copy to a new folder | cgkmal | Shell Programming and Scripting | 4 | 06-20-2009 01:12 PM |
| Find but exclude directories | tadi18 | Shell Programming and Scripting | 9 | 09-12-2008 11:34 AM |
|
|