I am using this for loop in the linux terminal:
for i in {1..21}; do
Here the script makes the loop go from 1 to 21.
How would I write the for loop, so that it goes through specific numbers; let's say:
9, 24, 29, 32, 38.
I am using Terminal on Linux.
答案 0 :(得分:2)
For a fixed list of numbers, just put them after in separates by spaces:
for i in 9 24 29 32 38
do
echo $i
done
答案 1 :(得分:0)
third argument is incremental sequence by default it take 1
for i in {0..21..9};
do
echo "$i"
done
but there is no pattern as you need