how to compare file modification time in bourne shell script

andre andre at targon.UUCP
Thu Jul 26 21:16:43 AEST 1990


  In article <1990Jul23.233044.2729 at silma.com> aab at 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

  what about

  if [ -n "`find file2 -newer file1 -print`" ]
  then
    echo file2 is newer
  else
    echo file2 is not newer
  fi

-- 
The mail|    AAA         DDDD  It's not the kill, but the thrill of the chase.
demon...|   AA AAvv   vvDD  DD        Ketchup is a vegetable.
hits!.@&|  AAAAAAAvv vvDD  DD                    {nixbur|nixtor}!adalen.via
--more--| AAA   AAAvvvDDDDDD    Andre van Dalen, uunet!hp4nl!targon!andre



More information about the Comp.unix.questions mailing list