date subtraction using numbers

view full story

http://www.linuxquestions.org – Hello I have logfiles like below. I want the get the date of the oldest log in this directory and compare it with current date. Time of the each log can be seen before ".Z" prefix. I have written the following piece of code. However, it is not working for the following case: LOGDAY=20101129 TODAY= 20101201 Difference is 72, which is not correct, since these are dates. How can I fix this? ls /archive_store akprd_uwprod_0000015702_1_201011121305.Z akprd_srprod_0000099047_1_201011121305.Z ... ... ... #!/bin/sh DIR=/archive_store TODAY=`date '+%Y%m%d'` cd ${DIR} file=$ (HowTos)