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