Problem with find(1)
Leo de Wit
leo at philmds.UUCP
Fri Sep 30 21:47:01 AEST 1988
In article <2935 at jpl-devvax.JPL.NASA.GOV> lwall at jpl-devvax.JPL.NASA.GOV (Larry Wall) writes:
>In article <815 at philmds.UUCP> leo at philmds.UUCP (Leo de Wit) writes:
>: Use the inode number of the directory instead of the name. This should be
>: unique. Assuming you use the Bourne shell:
>:
>: set `ls -di /news/spool`
>: find / -inum $1 -prune -o -print ...
>
>We will remind the listeners that an inode number by itself is not necessarily
>unique. A file on a different device could easily have the same inode number.
>If that happens to be a directory...
Yes, my mistake. This can perhaps be circumvented by pruning the
directories that are in fact filesystems, doing a find in each
filesystem and only doing the -inum $1 prune in the filesystem
containing the spool directory, so we have
find $root -inum 2 -prune -o -print
if spool is not contained in the tree (isn't inum == 2 <==> filesystem ?),
and
find $root -inum 2 -prune -o -inum $1 -prune -o -print
if spool IS contained in the tree. A new problem is that this already
fails when $root is a filesystem (for $root is already pruned then), so
we have to start the finds in each subdirectory of the filesystems. The
filesystem that contains the spool dir can be found by looking into
/etc/fstab (by hand or automatically).
Larry Wall also mentioned the absence of a -dnum option. It puzzles me why
this option is left out, because nearly all members of the stat struct can
be specified with find. Why not this one?
Someone else offered a solution that removes the spool directories by
piping to egrep -v. I think this is a portable solution, however it
does not take advantage of -prune for those who have it, for that will
speed up find a lot if the directory pruned is the top of a large
tree.
Leo.
P.S. I leave the solution of the original problem using -prune and
-inum in the way lined out as a puzzle, that is: find a nice
implementation. Any volunteers?
find /idea -type solution -user yourself -ok cat {} \; |
Pnews -h 'Re: Problem with find(1)'
More information about the Comp.unix.wizards
mailing list