Path: utzoo!attcan!uunet!mcvax!hp4nl!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.unix.wizards Subject: Re: Problem with find(1) Message-ID: <824@philmds.UUCP> Date: 30 Sep 88 11:47:01 GMT References: <108@forsight.Jpl.Nasa.Gov> <815@philmds.UUCP> <2935@jpl-devvax.JPL.NASA.GOV> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 49 In article <2935@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: >In article <815@philmds.UUCP> leo@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)'