Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!rutgers!njin!uupsi!sunic!dkuug!diku!jensen From: jensen@diku.dk (J|rgen Jensen) Newsgroups: comp.unix.shell Subject: Re: Comparing modified times of files Message-ID: <1991Mar31.191541.7351@odin.diku.dk> Date: 31 Mar 91 19:15:41 GMT References: <930001@mjm.mjm.com> <6350@amc-gw.amc.com> <6067@iron6.UUCP> <787r01De4aF300@amdahl.uts.amdahl.com> Sender: news@odin.diku.dk (Netnews System) Organization: Department of Computer Science, U of Copenhagen Lines: 47 krs@uts.amdahl.com (Kris Stephens [Hail Eris!]) writes: >In article <6067@iron6.UUCP> yeates@motcid.UUCP (Tony J Yeates) writes: >>krs@uts.amdahl.com (Kris Stephens [Hail Eris!]) writes: >> >>># sh or ksh fragment >>>newest() { >>> set -- ls -t $* 2>/dev/null >>> echo $1 >>> } >>>oldest() { >>> set -- ls -rt $* 2>/dev/null >>> echo $1 >>> } >> >>Can you have functions in Bourne Shell scripts? I thought this was >>only available in Ksh. > >Well, it works in my Bourne shell. :-) >...Kris >-- well, *functions* work in my Bourne shell too, but the above doesn't -- shouldn't a pair of back-ticks (`) enter into the thing somewhere?-) my favorite way of comparing the recentness of *two* files follows (I believe that was the original poster's problem): : #!/bin/sh - # if find $1 -newer $2 -print -o -prune | read a then echo $1 is newer than $2 fi # if your find doesn't have a "-prune"-predicate this # won't work for directories. some older finds (SysV?) # didn't support filenames where "$1" is inserted # -- i think -- then this won't work at all, of course. -- . . . . . . . . . . . . . . . . . . . . . . . . . . j e n s e n (jensen@diku.dk) Opinions? -- These are rock-solid facts!