Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: impossible problem for find(1)? Message-ID: <6454@mimsy.UUCP> Date: Fri, 24-Apr-87 21:10:44 EST Article-I.D.: mimsy.6454 Posted: Fri Apr 24 21:10:44 1987 Date-Received: Sun, 26-Apr-87 00:35:33 EST References: <2645@phri.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 43 In article <2645@phri.UUCP> roy@phri.UUCP (Roy Smith) writes: >[problem:] find all the files named *refs which are newer than a >file called INDEX in the same directory [as the *refs files]. If you have the `newer' program, this is easy: use -exec and a short script that runs newer on the given file and the equivalent INDEX file. Without newer, the most efficient way to tackle this is, probably, to first list all the `*refs' files with directories: find . -name \*refs -print | Break up the result by directory name: awk -F/ '{ dir = substr($0, 1, length($0) - length($NF)); if (dir != last) { if (any) print "/shazam"; any = 0; } else { if (any == 0) { any = 1; print "testthem " dir " << \\/shazam" } print $NF } }' | sh The `testthem' script then looks something like this: cd $1 if [ ! -f INDEX ]; then echo "$1: no INDEX file" cat # list them all exit 1 fi echo $1 find `cat` -newer INDEX -print and of course you can play games with formatting. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) UUCP: seismo!mimsy!chris ARPA/CSNet: chris@mimsy.umd.edu