Hi,
#!/usr/bin/sh
file=`ls -t1 $1| tail -1`
file2=`ls -t1 $1| tail -2 | head -1`
ar -r foo $1/$file
timer=`tail -1 foo | awk -F' ' '{print $2}'`
echo "Original file $file " `echo "0d$timer=Y" | adb | tr -d '\011'`
timer=`expr $timer + 120`
newdate=`echo "0d$timer=Y" | adb | tr -d '\011' `
year=`echo $newdate | awk '{print $1}'`
month=`echo $newdate | awk '{print $2}'`
day=`echo $newdate | awk '{print $3}'`
time=`echo $newdate | awk '{print $4}'`
hour=`echo $time | awk -F':' '{print $1}'`
min=`echo $time | awk -F':' '{print $2}'`
typeset -u mmm=`echo $month`
typeset -u months=`cal $year | grep "[A-Z][a-z][a-z]"`
i=1
for mon in $months
do
if [ "$mon" != "$mmm" ]
then
i=`expr $i + 1`
else
typeset -xZ2 i
month=$i
fi
done
echo "touch -t $year$month$day$hour$min $1/$file2"
Assuming your files are in ./test
$ ll ./test
total 0
-rw-rw-rw- 1 xxxxxxxx users 0 Feb 20 12:00 file1
-rw-rw-rw- 1 xxxxxxxx users 0 Feb 20 09:00 file2
$
Running:
./a.sh ./test
Original file file2 2007 Feb 20 09:00:00
touch -t 200702200902 ./test/file1
$
Have you thought about reversing the date listing with ls -lrt ?
Please also read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33 on how to reward any useful answers given to your questions.