Path: utzoo!attcan!uunet!mcsun!hp4nl!phigate!ehviea!leo From: leo@ehviea.ine.philips.nl (Leo de Wit) Newsgroups: comp.unix.questions Subject: Re: how to compare file modification time in bourne shell script Summary: Use make Message-ID: <840@ehviea.ine.philips.nl> Date: 25 Jul 90 08:33:09 GMT References: <1990Jul23.233044.2729@silma.com> Reply-To: leo@ehviea.UUCP (Leo de Wit) Organization: Philips I&E Eindhoven Lines: 28 In article <1990Jul23.233044.2729@silma.com> aab@silma.UUCP () writes: | |I need to compare the modification times of two files in a bourne shell |script. I would like to do this without writing C code. |Machine is Sparcstation 1 running SunOS 4.03c | |Thus I need a function: | |newer file1 file2 | |that returns 0 if file1 is newer than file2 else returns 1 | |Can it be done? This is simple if you let make decide: case `echo "file1 : file2; :"| make -f -` in :) echo file1 is older than file2;; *) echo file1 is newer than file2;; esac (this does not exactly return 0 or 1, but you get the intent). On the other hand, many scripts I encounter that have to decide whether file1 is newer than file2 are of type makefile; you might want to check whether your problem fits this category. Leo.