Wednesday, 4 September 2013

How to Sum Date with Bash

How to Sum Date with Bash

I need some help here, i'm not a expert with shell scripting but i am
trying to do a script where i need to take the Epoch number followed by
the date, but for with the all hours of the day with a interval of 15
minutes. The result will be something like this >
1376708400|2013-08-17 00:00:00 1376709300|2013-08-17 00:15:00
1376710200|2013-08-17 00:30:00 1376711100|2013-08-17 00:45:00
1376712000|2013-08-17 01:00:00 1376712900|2013-08-17 01:15:00
1376713800|2013-08-17 01:30:00 1376714700|2013-08-17 01:45:00
1376715600|2013-08-17 02:00:00 1376716500|2013-08-17 02:15:00
1376717400|2013-08-17 02:30:00 ...And it goes In the total i`ll have 96
lines, my biggest doubt right now is how i can increment (or sum) the
minutes by 15 minutes, i have tried this
My full script right now is this( i know is terrible, but im not a trully
programmer..im learning rsrs)
i=96
_incrementatime='+15 minutos'
count=1
_Date=$(`date "2013-08-29 00:00:00"`)
_dataEmSeg = `date -d "2013-08-29 00:00:00" +%s`
while test $i -ne 0
do
_VarData=$(`date --date="$_incrementatime*count"`)
_exprt=$(expr `$_Date+$_VarData`)
echo "$_dataEmSeg e $_exprt "
i=$((i-1))
count=$((count+1))
done
If someaone can give me the directions to resolve this i`ll be very
thankfull. OBS> Sorry for the grammar errors, english is not my first
language rs.
Thanks Guys

No comments:

Post a Comment