how to compare file modification time in bourne shell script
Bj|rn Munch
bjornmu at idt.unit.no
Wed Jul 25 08:01:36 AEST 1990
In article <1990Jul23.233044.2729 at silma.com>, aab at silma.com (Andy
Burgess) 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
|>
I needed the same thing once, and did it this way:
test `ls -lt file1 file2 | head -1 | grep file1`
This will not work if the name file1 is a substring of file2...
It really ought to be simpler; after all, ls *has* the information you
want, the rest is just needed to translate it.
___________________________________________________________________________
Bj|rn Munch | Div. of Comp. Science & Telematics,
bjornmu at idt.unit.no | Norwegian Institute of Technology (NTH),
"The Man With a Pipe in His Name" | Trondheim, Norway
More information about the Comp.unix.questions
mailing list