Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!hc!beta!cmcl2!phri!roy From: roy@phri.UUCP (Roy Smith) Newsgroups: comp.unix.wizards Subject: impossible problem for find(1)? Message-ID: <2645@phri.UUCP> Date: Thu, 23-Apr-87 20:57:02 EST Article-I.D.: phri.2645 Posted: Thu Apr 23 20:57:02 1987 Date-Received: Sat, 25-Apr-87 19:02:02 EST Reply-To: roy@phri.UUCP (Roy Smith) Organization: Public Health Research Inst. (NY, NY) Lines: 61 A user posed a problem which I can't solve. She wants to find all the files named *refs which are newer than a file called INDEX in the same directory. Thus she wants to know if any of ./x/foorefs, ./x/barrefs or ./x/bazrefs is newer than ./x/INDEX, and if ./y/z/refs is newer than ./y/z/INDEX, etc. I can't think of how to do this with find, or even any combination of find and any other standard tools. We're running MtXinu 4.3BSD/NFS on a Vax and Sun-3.1 on some Sun-3's. The obvious % find . "*refs" -newer INDEX -print finds *refs files which are newer than INDEX in the directory in which I ran the find. This is not, unfortunately, what I need. The Sun version of make has a -q option which I could use to do something like % find . -name INDEX -exec make -q INDEX ';' but this will only work on the Suns, and there is still the problem of how to phrase the Makefiles and where to put them. Of course, if the MtXinu NFS support worked better I would contemplate running this on a Sun CPU mounting the Vax disk, but it doesn't, so I won't. I could envision something horrible along the lines of % find . -type d -exec find '{}' -type d -prune -name '"*refs"' \ -newer INDEX -exec pwd -print '";"' ';' but I no longer do the type of drugs required to seriously contemplate doing that. I havn't wasted the time to get the exact syntax of the above correct so please don't bother flaming me about messing up the double layer of quotes or some other silly detail. It was meant as a general idea, not a finished product. Note that you need the "-exec pwd" in the inner-level find because all "-print" will say is "./foorefs" which isn't useful. Another hair-brained (a cross between hairy and brain-damaged?) idea centers around doing "ls -lt INDEX *refs" and checking to see that the first output line contains (or actually doesn't contain) INDEX, perhaps by piping it through "head -1 | grep INDEX". This gives (roughly) % find . -type d \ -exec sh -c 'ls -lt {}/INDEX {}/*refs | head -1 | egrep -vs INDEX' ';' \ -print which is also too sick to think about doing, let alone explaining to a non-wizard. Besides, I wouldn't count on the "sh -c" to properly pass back the exit status of the pipeline (earlier Berkeley versions of sh did this wrong; I have no idea if the 4.3 version is fixed or not), and you run into problems if the sh dies because the *refs expansion doesn't work in a particular directory. Is there really no easy way to do this? -- Roy Smith, {allegra,cmcl2,philabs}!phri!roy System Administrator, Public Health Research Institute 455 First Avenue, New York, NY 10016 "you can't spell deoxyribonucleic without unix!"