having problems with 'find' command

having problems with 'find' command

Post by Alim Man » Tue, 08 Jun 1999 04:00:00



Hi all,

i'm having a lot of problems with 'find', and I get the
feeling they are well known problems, I was wondering if
anyone would be able to help me out. The problem is that
the -local switch doesn't seem to work. It reads the
file /etc/dfs/dfstypes or something like that for a list
of remote file system types, and is SUPPOSED to skip the
file systems of those types when searching, but it
doesn't. I have tried various ways to get around this,
including -fstype nfs -prune. I can't seem to get it to
work! All I want is to have 'find' search the hard drives
for core files and remove them.

Any help is appreciated.
Thanks,
Alim.

 
 
 

having problems with 'find' command

Post by dharz.. » Tue, 08 Jun 1999 04:00:00



Quote:> i'm having a lot of problems with 'find',
> The problem is that the -local switch doesn't seem to work.
> I have tried various ways to get around this,
> including -fstype nfs -prune. I can't seem to get it to
> work!

Hrm.
Did you try -mount or -fstype ufs?

Noal
--
"Sure, it's every American's right to post false or misleading
information on the Internet."
-The Detroit News

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

having problems with 'find' command

Post by hwk.. » Tue, 08 Jun 1999 04:00:00




Quote:> Hi all,

> i'm having a lot of problems with 'find', and I get the
> feeling they are well known problems, I was wondering if
> anyone would be able to help me out. The problem is that
> the -local switch doesn't seem to work. It reads the
> file /etc/dfs/dfstypes or something like that for a list
> of remote file system types, and is SUPPOSED to skip the
> file systems of those types when searching, but it
> doesn't. I have tried various ways to get around this,
> including -fstype nfs -prune. I can't seem to get it to
> work! All I want is to have 'find' search the hard drives
> for core files and remove them.

> Any help is appreciated.
> Thanks,
> Alim.

This sounds very familiar.  To the best of my knowledge, find still
descends into NFS mounted filesystems even with those options.  It just
won't match anything that would otherwise match on those mounts.

I usually just specify the directory, knowing it is not NFS mounted:

find /usr/local -name core -exec rm {} \;

If anyone has a way to physically skip NFS I'd love to hear it myself.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

having problems with 'find' command

Post by Richard L. Hamilt » Tue, 08 Jun 1999 04:00:00




Quote:> Hi all,

> i'm having a lot of problems with 'find', and I get the
> feeling they are well known problems, I was wondering if
> anyone would be able to help me out. The problem is that
> the -local switch doesn't seem to work. It reads the
> file /etc/dfs/dfstypes or something like that for a list
> of remote file system types, and is SUPPOSED to skip the
> file systems of those types when searching, but it
> doesn't. I have tried various ways to get around this,
> including -fstype nfs -prune. I can't seem to get it to
> work! All I want is to have 'find' search the hard drives
> for core files and remove them.

You can work around any such problem by generating the list of
directories on which "find" is expected to work.  For example:
========================= cut here ============================
#! /bin/sh
#
# Do yourself a favor and notify the users of the policy that this
# script implements!
#
# The clause   && substr($1,1,5)!="/vol/"
# is intended to exclude media mounted via the volume manager, under
# the assumption that such media tends to be a private rather than
# shared resource.  Also, by keeping "find" out of volume manager mounted
# directories, it prevents this script from causing "eject" to fail
# unexpectedly due to the filesystem being busy by something not
# running at the initiative of the console user.
#
# One could of course remove that, but I don't recommend it.
#
# Days to allow a core file to linger, in case someone actually wants
# to use it to _fix_ the reason it was produced in the first place.
#
GracePeriod=7
#

PATH=/usr/bin;export PATH

for Dir in \
   ` awk '( $3=="ufs" || $3=="tmpfs") && substr($1,1,5)!="/vol/" {print $2}' \
     /etc/mnttab `
do
   find "${Dir}" -mount -mtime +"${GracePeriod}" -type f -name core \
      -print | xargs rm -f
done
========================= cut here ============================

The -mount (or equivalent -xdev) option of "find" is important:
it prevents "find" from crossing a mount-point into another
filesystem.

One could go further and have a file that looked like:
# mount-point     grace_period
/tmp              1
/var/tmp          1
/export/home      7

and write a script that operated against such a file instead,
to allow the additional flexibility.  But that's overkill for
a simple example.

--
ftp> get |fortune
377 I/O error: smart remark generator failed

Bogonics: the primary language inside the Beltway


 
 
 

having problems with 'find' command

Post by Alim Man » Wed, 09 Jun 1999 04:00:00



: > i'm having a lot of problems with 'find',
: > The problem is that the -local switch doesn't seem to work.
: > I have tried various ways to get around this,
: > including -fstype nfs -prune. I can't seem to get it to
: > work!

: Hrm.
: Did you try -mount or -fstype ufs?

: Noal
: --
: "Sure, it's every American's right to post false or misleading
: information on the Internet."
: -The Detroit News

: Sent via Deja.com http://www.deja.com/
: Share what you know. Learn what you don't.

No, but i'm going to right now!
Thanks!
Alim.

 
 
 

having problems with 'find' command

Post by Alim Man » Thu, 10 Jun 1999 04:00:00



: : > i'm having a lot of problems with 'find',
: : > The problem is that the -local switch doesn't seem to work.
: : > I have tried various ways to get around this,
: : > including -fstype nfs -prune. I can't seem to get it to
: : > work!

: : Hrm.
: : Did you try -mount or -fstype ufs?

: : Noal
: : --
: : "Sure, it's every American's right to post false or misleading
: : information on the Internet."
: : -The Detroit News

: : Sent via Deja.com http://www.deja.com/
: : Share what you know. Learn what you don't.

: No, but i'm going to right now!
: Thanks!
: Alim.

Well, I tried -mount, it seems to skip ALL mounts, so it actually checks
too little. And I tried -fstype ufs, for some reason that still check
/usr/local, which is nfs mount from file server. I don't understand why
the -local switch won't work, that is exactly the functionality I am
looking for!

Alim.

 
 
 

having problems with 'find' command

Post by dharz.. » Thu, 10 Jun 1999 04:00:00



Quote:> Well, I tried -mount, it seems to skip ALL mounts,

You have to specify the filesystems with -mount.
From the man page:

 -mount         Always true; restricts the search to the file
                system  containing  the  directory specified.
                Does not list mount points to other file sys-
                tems.

It may require a longer find statement, but it should still work.

Quote:> I tried -fstype ufs, for some reason that still check /usr/local,
> which is nfs mount from file server.

That's odd.  Perhaps it checked it on the basis of it being a subdir of
/usr...  *shakes head*

Quote:> I don't understand why the -local switch won't work, that is exactly
> the functionality I am looking for!

That does seem odd.  According to what I've seen, -local typically
physically checks the partition but excludes it from matching the search
criteria.

--
"Sure, it's every American's right to post false or misleading
information on the Internet."
-The Detroit News

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

having problems with 'find' command

Post by dharz.. » Thu, 10 Jun 1999 04:00:00



Quote:> I don't understand why the -local switch won't work, that is
> exactly the functionality I am looking for!

     -local         True if the file system type is not a  remote
                    file   system   type   as   defined   in  the
                    /etc/dfs/fstypes file.  nfs is  used  as  the
                    default   remote   filesystem   type  if  the
                    /etc/dfs/fstypes file is not present.

Check to make sure that nfs is listed in this file.

Noal
--
"Sure, it's every American's right to post false or misleading
information on the Internet."
-The Detroit News

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

having problems with 'find' command

Post by Andrew Gabri » Thu, 10 Jun 1999 04:00:00






>> Hi all,

>> i'm having a lot of problems with 'find', and I get the
>> feeling they are well known problems, I was wondering if
>> anyone would be able to help me out. The problem is that
>> the -local switch doesn't seem to work. It reads the
>> file /etc/dfs/dfstypes or something like that for a list
>> of remote file system types, and is SUPPOSED to skip the
>> file systems of those types when searching, but it
>> doesn't. I have tried various ways to get around this,
>> including -fstype nfs -prune. I can't seem to get it to
>> work! All I want is to have 'find' search the hard drives
>> for core files and remove them.

>> Any help is appreciated.
>> Thanks,
>> Alim.

>This sounds very familiar.  To the best of my knowledge, find still
>descends into NFS mounted filesystems even with those options.  It just
>won't match anything that would otherwise match on those mounts.

>I usually just specify the directory, knowing it is not NFS mounted:

>find /usr/local -name core -exec rm {} \;

>If anyone has a way to physically skip NFS I'd love to hear it myself.

find `awk '$3=="ufs" {print $2}' /etc/mnttab` -mount -name core -exec rm {} \;

will only traverse ufs filesystems, but will still include a
ufs filesystem whose mount point is inside an NFS filesystem

(Incidently, this is why -local still traverses remote filesystems,
but the above solves that more efficiently, at least for ufs and
NFS filesystems.)

--
Andrew Gabriel
Consultant Software Engineer

 
 
 

having problems with 'find' command

Post by Alim Man » Thu, 10 Jun 1999 04:00:00



: > I don't understand why the -local switch won't work, that is
: > exactly the functionality I am looking for!

:      -local         True if the file system type is not a  remote
:                     file   system   type   as   defined   in  the
:                     /etc/dfs/fstypes file.  nfs is  used  as  the
:                     default   remote   filesystem   type  if  the
:                     /etc/dfs/fstypes file is not present.

: Check to make sure that nfs is listed in this file.

I did. It is.

: Noal
: --
: "Sure, it's every American's right to post false or misleading
: information on the Internet."
: -The Detroit News

: Sent via Deja.com http://www.deja.com/
: Share what you know. Learn what you don't.

 
 
 

having problems with 'find' command

Post by Joe Bottom » Fri, 11 Jun 1999 04:00:00


How about pruning the unwanted file systems...

ex...

find / -name core -ok rm {} \; -o \( -name ___ -prune -o -name ___ -prune \)

name ___ would be something like \/NFS_DIR ...

Just a thought...






> >> Hi all,

> >> i'm having a lot of problems with 'find', and I get the
> >> feeling they are well known problems, I was wondering if
> >> anyone would be able to help me out. The problem is that
> >> the -local switch doesn't seem to work. It reads the
> >> file /etc/dfs/dfstypes or something like that for a list
> >> of remote file system types, and is SUPPOSED to skip the
> >> file systems of those types when searching, but it
> >> doesn't. I have tried various ways to get around this,
> >> including -fstype nfs -prune. I can't seem to get it to
> >> work! All I want is to have 'find' search the hard drives
> >> for core files and remove them.

> >> Any help is appreciated.
> >> Thanks,
> >> Alim.

> >This sounds very familiar.  To the best of my knowledge, find still
> >descends into NFS mounted filesystems even with those options.  It just
> >won't match anything that would otherwise match on those mounts.

> >I usually just specify the directory, knowing it is not NFS mounted:

> >find /usr/local -name core -exec rm {} \;

> >If anyone has a way to physically skip NFS I'd love to hear it myself.

> find `awk '$3=="ufs" {print $2}' /etc/mnttab` -mount -name core -exec rm {} \;

> will only traverse ufs filesystems, but will still include a
> ufs filesystem whose mount point is inside an NFS filesystem

> (Incidently, this is why -local still traverses remote filesystems,
> but the above solves that more efficiently, at least for ufs and
> NFS filesystems.)

> --
> Andrew Gabriel
> Consultant Software Engineer

 
 
 

1. Piping results of a 'find' command to a 'mv' command...

Is there a way to do the following without scripting:

Pipe the contents of a 'find' command to a 'mv' command, so that the
results of 'find', example:

find / -iname '*simpsons*' 2>>/dev/null

/home/shawn/downloads/simpsons1.mpg
/home/shawn/simpsons/Halloween Special IX.mpg
/home/shawn/unsorted/simpsons02.mpg

are all moved to a folder of my choosing:

Something like:
find / -iname '*simpsons*' 2>>/dev/null | mv /home/shawn/tv/simpsons

Can anyone help?  If scripting is required, I don't mind, but I
thought that if there was an easy way, I'd like to use it.

If scripting is required, is there an easy way to do it just by
creating a script containing a list of commands and running it after
chmod +x?  Or would I have to do something with Perl in order to loop
through the results of the 'find'?

I know a little Perl, but if there is some other type of scripting
preferred for this type of thing, please tell me the name of it and
where I might find a little documentation.

Thank you for any help you can give.  And please, even if the answer
can be derived from a particular command, do not simply type 'man
commandName'.  A little description/advice would be very nice.

Shawn

2. make problems...

3. usage of 'foreach' and 'find' commands

4. Trying to compare distributions

5. Need to find info on the 'FIND' command

6. display

7. Usind 'find' command to find certain text within a file

8. modem in RH6.2

9. Kernel Compile Problems - 'as86 command not found'

10. 'Find' 'Updatedb' or find database replacement for Solaris 2.X?

11. problems with the 'w' command -- not showing 'what'\

12. Problem with ''make'' command in RH 6.0

13. 'find' and 'rm' problems