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:

find / -name '/export/home' -prune -o print -ls
  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

I dont get you here, what are you looking for?
If /export/home is a separate filesystem, why are you looking for it then?

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

Do not use -name, use -path (I hope it works in Solaris):

find / -type d -path /export/home -prune -o -ls

A workaround for find without -path:

find / -type d -name home -exec test {} = /export/home \; -prune -o -ls

The -name home expression is not required, but it saves work by preventing -exec test ... when it cannot possibly succeed.

Regards,
Alister

Another way. Work from the mounted filesystem list and ignore /export/home .

#!/bin/ksh
mount | awk '{print $1}' |grep -v "\/export\/home" | sort | while read filesystem
do
     find ${filesystem} -xdev -type f -print
done

The "-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.

Hi All,

Thanks to all 3 respondent to my queries. Below are the out the outcome from your suggestions:

find: bad option -path
find: [-H | -L] path-list predicate-list (Solaris does not support -path syntax)

Brief to the point and works fine and make use of all the functionalities available in find.

Too much scripting which doesn't make use of all the built-in features in find even though it also worked.

The second suggestion is most useful even though it is much appreciated for all your inputs.

Thanks,

George