1753970 Members
7743 Online
108811 Solutions
New Discussion юеВ

Script help with pruning

 
SOLVED
Go to solution
shell script
Advisor

Script help with pruning

Hello,

I have the following code and I would like to exclude the nfs and mvfs file systems from the find command. Please advise.

case "$OSTYP" in
AIX) find / -name "/proc" -prune -o \
\( -fstype jfs -o -fstype jfs2 \) \
\( -nouser -o -nogroup\)
;;

Thanks in advance.
9 REPLIES 9
James R. Ferguson
Acclaimed Contributor

Re: Script help with pruning

Hi:

Frankly I find the 'prune' option of find() variable among different UNIX flavors and troublesome to specify. Consider something like this:

# find / \( ! -fstype nfs \) -o \( -nouser -o -nogroup \)|grep -Ev '/proc|/mvfs'

Regards!

...JRF...
shell script
Advisor

Re: Script help with pruning

No it does not work. It gives me false files (files having valid UID and GID).

More thoughts??
James R. Ferguson
Acclaimed Contributor
Solution

Re: Script help with pruning

Hi:

Sorry, I 'or'ed when I should have 'and'ed.

# find / \( ! -fstype nfs \) -a \( -nouser -o -nogroup \)|grep -Ev '/proc|/mvfs'

Regards!

...JRF...
shell script
Advisor

Re: Script help with pruning

Thanks JRF that worked perfectly fine. Lastly, how do I add a word count of the number of files found by the find command. Currently I have
find / \( ! -fstype nfs \) -a \( -nouser -o -nogroup \) -print | xargs ls -ld |grep -Ev '/proc|/mvfs'
James R. Ferguson
Acclaimed Contributor

Re: Script help with pruning

Hi (again):

To count the files simply do:

# find / \( ! -fstype nfs \) -a \( -nouser -o -nogroup \) |grep -Ev '/proc|/mvfs'|wc -l

If you want a long-listing of the files, then:

# find / \( ! -fstype nfs \) -a \( -nouser -o -nogroup \) -exec ls -ld {} + | grep -Ev '/proc|/mvfs'

Regards!

...JRF...
Peter Nikitka
Honored Contributor

Re: Script help with pruning

Hi,

in addition to JRFs solutiuon; I want to remember the grep-option '-c', which counts matches.
# find / \( ! -fstype nfs \) -a \( -nouser -o -nogroup \) |grep -Evc '/proc|/mvfs'

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
shell script
Advisor

Re: Script help with pruning

Actually it is still trying to find the "mvfs" file system. I had tried it earlier on systems without the virtual file system mvfs.

find / \( ! -fstype nfs \) -a \( -nouser -o -nogroup \) -exec ls -ld {} + | grep -Ev '/proc|/mvfs'
is failing. Please help.
OldSchool
Honored Contributor

Re: Script help with pruning

"find / \( ! -fstype nfs \) -a \( -nouser -o -nogroup \) -exec ls -ld {} + | grep -Ev '/proc|/mvfs'
is failing. Please help."

describe "failing". also note that the grep command noted should toss anything the that has /proc or /mvs in the name ...

like /a/proc or /b/mvs.......
James R. Ferguson
Acclaimed Contributor

Re: Script help with pruning

Hi (again):

> Actually it is still trying to find the "mvfs" file system.

Now you are better off consulting IBM/AIX documentation. As I understand it, 'MVFS' stands for "Multi-Verion-File-System". It appears that these are mounted under the directory name '/view'. Hence all I can offer is to include or exclude this directory as we have discussed previously in this thread.

By the way, you ought to change your Formum name from "shell script" to a more suitable moniker that represents _you_.

Regards!

...JRF...