Operating System - HP-UX
1838263 Members
3619 Online
110125 Solutions
New Discussion

find cmd to avoid nfs and rm core

 
SOLVED
Go to solution
James OReilly
Occasional Contributor

find cmd to avoid nfs and rm core

I'm using the find cmd to find cores and them compress them to be looked at a later time.

The problem I'm having is trying to rm the compressed core after 7 days. The find cmd just prints the file name but does not rm the core.Z file.

cmd that is failing:
/bin/find / -type f -name core.Z -mtime +7 -print -o -fstype nfs -prune -exec rm {} \;

If I run the same cmd but pipe it to a while read statement it does rm the core.Z file.

cmd that works:
/bin/find / -type f -name core.Z -mtime +7 -print -o -fstype nfs -prune | while read name
do
rm "$name"
done

Thanks,
Jim

2 REPLIES 2
Alzhy
Honored Contributor
Solution

Re: find cmd to avoid nfs and rm core

find / -fsonly vxfs ...
Hakuna Matata.
harry d brown jr
Honored Contributor

Re: find cmd to avoid nfs and rm core

What are you trying to "OR" (-o) ?? Use parens to get what you want:

find / -type f -name core.Z \( -mtime +7 -o -fstype nfs \) -exec rm {} \;

-prune is not necessary if you are specifiying that you want only "files" (-type f).

live free or die
harry
Live Free or Die