I'm trying to create sequences as follows:
startDay=1
endDay=2
dayRange="{$startDay..$endDay}"
echo \[\"$dayRange\",\"{00..02}\"\]
The output is:
["{1..2}","00"] ["{1..2}","01"] ["{1..2}","02"]
When specifying the sequence directly {00..02}, it auto creates "00", "01", "02", but it does not understand the dayRange variable.
What I expect it to return is:
["1","00"] ["1","01"] ["1","02"] ["2","00"] ["2","01"] ["2","02"]
Not sure what I missed. Please advise.
First idea would be a simple nested
forloop:This generates:
A bit less coding, and a bit faster, which uses OP's
echo ... {00..02}to eliminate one of theforloops:NOTE: this eliminates the subprocess
$(echo ...)call I had in a previous edit.This also generates:
Here's one
awkidea:This also generates:
With the elimination of the earlier subprocess
$(echo ...)the first 2 solutions come in with single-digit millisecond timings while theawksolution comes in with low double-digit millisecond timings.As the number of days (and/or sequence size) increases the first 2 solutions start taking longer (the nested
forloop falling farther behind) while theawksolution tends to maintain the same speed.For really large increases (number of days and/or sequence size) I would expect
awkto close in on, and eventually take, the lead.