4 ms·
Wanted a `for` loop between two numbers, couldn't find a good way in 10 minutes, made the script require `zsh`.
by pdimitar 6y ago
Wanted a `for` loop between two numbers, couldn't find a good way in 10 minutes, made the script require `zsh`.
- orbz 6y agoBash sequence expression didn't work? http://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Brace-Expansion http://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.h...
- pdimitar 6y agoYep, didn't know about that one. Guess my Google-fu failed me back then.
- m463 6y agowow, I was staring at it for a bit before I realized: for i in {1..10}; do echo $i; done worked and was equivalent to: for((i=1;i<=10;i++)); do echo $i; done for i in 1 2 3 4 5 6 7 8 9 10; do echo $i; done
- geocar 6y agoseq 5 10 | while read REPLY ... for x in `seq 5 10`; do ...
- mjaniczek 6y agoSomething like `seq 5 10`?
- eequah9L 6y agoBesides seq, this also works specifically in Bash: for ((i = 0; i < 10; i++)); do echo $i done