I want to limit sequence in for loop. All my tries were unsecsessfull. What Am I doing wrong?
I thought that this should work:
for x in ((seq 100)[50..55])
echo $x
end
With fish:
for i in (seq 50 55); echo "$i"; end
Output:
50 51 52 53 54 55
You have one too many pairs of parenthesis. In fish parenthesis do what $(command)
and `command`
do in bash or zsh. So just do
for x in (seq 100)[50..55]
echo $x
end
And, of course, for this specific example you don't even need the slice notation since you can just tell the seq command to begin and end with the desired values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With