Path: utzoo!attcan!uunet!lll-winken!uwm.edu!rpi!dali.cs.montana.edu!uakari.primate.wisc.edu!sdd.hp.com!ucsd!tut.cis.ohio-state.edu!mailrus!usenet.ins.cwru.edu!cwns1!chet From: chet@cwns1.CWRU.EDU (Chet Ramey) Newsgroups: comp.unix.questions Subject: Re: how to compare file modification time in bourne shell script Message-ID: <1990Jul27.144806.2681@usenet.ins.cwru.edu> Date: 27 Jul 90 14:48:06 GMT References: <1990Jul23.233044.2729@silma.com> Sender: news@usenet.ins.cwru.edu Reply-To: chet@po.CWRU.Edu Organization: Case Western Reserve Univ. Cleveland, Ohio, (USA) Lines: 33 >newer file1 file2 > >that returns 0 if file1 is newer than file2 else returns 1 If you didn't like the C program, then try this: newer() { if [ ! -f $1 ] ; then return 1 fi if [ ! -f $2 ] ; then return 0 fi if [ $1 -nt $2 ] ; then return 0 else return 1 fi } The `-nt' option to test exists in bash and ksh, at least. Chet -- Chet Ramey ``See Figure 1.'' Network Services Group Case Western Reserve University chet@ins.CWRU.Edu