Bash Nested Loops, mixture of dates and numbers -


i trying output range of commands different dates , numbers associated. each hour eg.

output im trying in loop is:

shell.sh filename<number e.g. between 1-24> <date e.g. 20100928> <number e.g. between 1-24> <id> 

so the above generate output done 24 times each particular day unique 4 digit id.

i thinking of having nested loop, batch number needs unique.

can help?

it not clear why need nested loop or whether need iterate on range of dates or not. script this:

#!/bin/bash  day_from=1 # first (starting) day day_to=24  # last day  date=$(date +%y%m%d) # date processing.  id=0 # number our unique id generation.      # being incremented each day.      # since variable in global scope,      # unique no matter how many dates process.      # if want unique id unique date scope,      # reset 0 before processing each date.  # let's go iterate on days. (( i=$day_from; <= $day_to; ++i ))     let ++id # increment our unique id number...     # print filename, date, number , unique id.     # %04d @ end means output integer     # 4 digits padded zeroes if needed.     printf "%s %s %s %04d\n" "filename$i" "$date" "$i" "$id" done 

... , output this:

filename1 20101007 1 0001 filename2 20101007 2 0002 filename3 20101007 3 0003 .... 

hope helps!


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -