← Linux and the Command Line
Lesson 48 of 51 · 5 XP
Warm-up: from 1 to n warm-up
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
while repeats a block while the condition is true. -le means "less than or equal":
read n
i=1
while [ "$i" -le "$n" ]; do
echo "$i"
i=$((i + 1))
done
Task. Read n and print the numbers from 1 to n, each on its own line.
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.