I was trying to write a BASH loop of the form:
~/$ for i in {1..$(grep -c "match" file)} ; do echo $i ; done
{1..20}
where I was hoping it would produce counted output. So I tried this instead:
~/$ export LOOP_COUNT=$(grep -c "match" file)
~/$ for i in {1..$LOOP_COUNT} ; do echo $i ; done
{1..20}
What I fell back to using was:
~/$ for i in $(seq 1 1 $(grep -c "match" file)) ; do echo $i ; done
1
2
3
...
20
Perfect! But how can I get that behaviour without using seq?
Have you tried this?