Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

I'm going to put the comments in an answer so the question can be resolved.

The problem is leading zeros. imgs/back_0008.hdr isn't the same as imgs/back_8.hdr. So the variable used in the filename needs to have leading zeros. imgs/back_${t}.hdr works for this example that runs from 8-12, but as soon as you have images up to 18, it will no longer work because both imgs/back_0008.hdr and imgs/back_0018.hdr match imgs/back_${t}.hdr when t=8.

for bash 4 you can use:

for t in {0008..0012} ; do

But OSX ships with bash 3. When using bash 3 on OSX i typically use printf to make a variable with leading zeros like this:

for t in {8..12}; do 
    ts=`printf "%04d" ${t}` ;
    evalglare -d -vf view/vh1.vf imgs/back_${ts}.hdr ;
done > gout/back_allresults.txt

Also, moving the redirect outside the loop sends all standard out generated within the loop to the same file.

I'm going to put the comments in an answer so the question can be resolved.

The problem is leading zeros. imgs/back_0008.hdr isn't the same as imgs/back_8.hdr. So the variable used in the filename needs to have leading zeros. imgs/back_${t}.hdr {t}.hdr works for this example that runs from 8-12, but as soon as you have images up to 18, it will no longer work because both imgs/back_0008.hdr and imgs/back_0018.hdr match imgs/back_${t}.hdr when t=8.

for bash 4 you can use:

for t in {0008..0012} ; do

But OSX ships with bash 3. When using bash 3 on OSX i typically use printf to make a variable with leading zeros like this:

for t in {8..12}; do 
    ts=`printf "%04d" ${t}` ;
    evalglare -d -vf view/vh1.vf imgs/back_${ts}.hdr ;
done > gout/back_allresults.txt

Also, moving the redirect outside the loop sends all standard out generated within the loop to the same file.

I'm going to put the comments in an answer so the question can be resolved.

The problem is leading zeros. imgs/back_0008.hdr isn't the same as imgs/back_8.hdr. So the variable used in the filename needs to have leading zeros. imgs/back_{t}.hdr imgs/back_*\${t}.hdr works for this example that runs from 8-12, but as soon as you have images up to 18, it will no longer work because both imgs/back_0008.hdr and imgs/back_0018.hdr match imgs/back_${t}.hdr imgs/back_*\${t}.hdr when t=8.

for bash 4 you can use:

for t in {0008..0012} ; do

But OSX ships with bash 3. When using bash 3 on OSX i typically use printf to make a variable with leading zeros like this:

for t in {8..12}; do 
    ts=`printf "%04d" ${t}` ;
    evalglare -d -vf view/vh1.vf imgs/back_${ts}.hdr ;
done > gout/back_allresults.txt

Also, moving the redirect outside the loop sends all standard out generated within the loop to the same file.

I'm going to put the comments in an answer so the question can be resolved.

The problem is leading zeros. imgs/back_0008.hdr isn't the same as imgs/back_8.hdr. So the variable used in the filename needs to have leading zeros. imgs/back_*\${t}.hdr imgs/back_*${t}.hdr works for this example that runs from 8-12, but as soon as you have images up to 18, it will no longer work because both imgs/back_0008.hdr and imgs/back_0018.hdr match imgs/back_*\${t}.hdr when t=8.

for bash 4 you can use:

for t in {0008..0012} ; do

But OSX ships with bash 3. When using bash 3 on OSX i typically use printf to make a variable with leading zeros like this:

for t in {8..12}; do 
    ts=`printf "%04d" ${t}` ;
    evalglare -d -vf view/vh1.vf imgs/back_${ts}.hdr ;
done > gout/back_allresults.txt

Also, moving the redirect outside the loop sends all standard out generated within the loop to the same file.