Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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 I'm not a truly programmer. I'm learning)


_incrementatime='+15 minutos'


_Date=$(`date "2013-08-29 00:00:00"`)
_dataEmSeg = `date -d "2013-08-29 00:00:00" +%s`

while  test $i -ne 0

    _VarData=$(`date --date="$_incrementatime*count"`)

    _exprt=$(expr `$_Date+$_VarData`)
    echo "$_dataEmSeg  e  $_exprt    "


If someone can give me the directions to resolve this I`ll be very thankfull.

share|improve this question
Is this bash or another shell? Looks like bash but you have not said. I also assume you are running some kind of *nix system. – terdon Sep 4 '13 at 21:15

If you are using GNU date, it can almost do everything itself:

#!/usr/bin/env bash

_Date=$(date -d "2013-08-29 00:00:00");
for ((i=0; i<96; i++)); do 
    echo $(date -d "$_Date" +%s)"|"$(date -d "$_Date" +"%F %T")
    _Date=$(date -d "$_Date +15 minutes")

There were various small errors and unnecessary steps in your script which I removed or corrected.

share|improve this answer

You didn't mention the system you're on, but there's dseq(1) from my dateutils collection to produce a sequence of dates:

$ dseq '2013-08-17 00:00:00' +15m '2013-08-18 00:00:00' -f '%s|%F %T'
1376697600|2013-08-17 00:00:00
1376698500|2013-08-17 00:15:00

The first 3 arguments denote the starting and end point of the sequence, the middle one being the increment (just like seq(1) really). The -f switch allows you to specify the output format, and takes format specifiers similar to those in GNU date.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.