Problem with find(1)

Larry Wall lwall at jpl-devvax.JPL.NASA.GOV
Tue Sep 27 03:23:58 AEST 1988


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

Since find doesn't have a -dnum option (that I know of), you could decrease
the odds of a false positive by checking both the inode and the name.

     find / \( -name 'news' -inum $1 -prune \) -o -print ...

Larry Wall
lwall at jpl-devvax.jpl.nasa.gov



More information about the Comp.unix.wizards mailing list