Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

increase time by n minutes

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL

hello,

begin hour is 00:00

I need to increase it by 5 minutes in loop to get:

00:05
00:10
00:15
...
...
23:50
23:55


Thank you in advance,
r.m.
 
Like this using
man seq for details

Code:
#! /bin/ksh
for HH in $(seq 0 23)
do
        for MN in $(seq 0 5 55 )
        do
                printf "%.2d:%.2d\n" $HH $MN
        done
done
 
Hi

You not specified your shell. If it is [tt]bash[/tt] :
Bash:
echo {[purple]00[/purple][teal]..[/teal][purple]23[/purple]}[teal]:[/teal]{[purple]00[/purple][teal]..[/teal][purple]59[/purple][teal]..[/teal][purple]5[/purple]}
Tested with [tt]bash[/tt] 4, in older versions not works. See Brace Expansion in [tt]man bash[/tt] for details.

Feherke.
 
if you don't have seq:

[tt]hh='0 1 2 4 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23'
mm='0 5 10 15 20 25 30 35 40 45 50 55'
for h in ${hh}
do
for m in ${mm}
do
time=$(printf "%02d:%02d\n" ${h} ${m})
echo $time
done
done[/tt]


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top