I am writing a script to find the difference between file creation/modification times using a bash script. Running QNX I cannot use any common themed date functions that would make this easy. I am currently approaching this modifying the date from the ls command:
last=0
current=0
#ls -l /path/*.log | awk '{print $8}' | sed s/:/*60+/g | bc |
ls -l /path/*.log | awk '{print $8}' |
while read fname
do
current=$(fname | sed s/:/*60+/g | bc)
echo $current
echo $fname
if [ $last -gt 0 ]; then
echo "the difference is $($current - $last) minutes"
last=$current
else
last=$current
echo $fname
fi
done
the first commented ls produces what I need, the time in seconds, the while statement doesnot work though, not being able to find an integer based file. If I use the second ls command the sed will not modify the hh:mm based date and the difference won't work. Any ideas?