← Linux and the Command Line Lesson 45 of 51 · 5 XP

Warm-up: greater than ten? warm-up

Theory and problem statement

Machine translation, not yet reviewed by a native speaker.

if checks the condition in square brackets. For numbers, "greater than" is written -gt:

read n
if [ "$n" -gt 10 ]; then
    echo big
else
    echo small
fi

The spaces inside [ ] are required, and the block ends with the word fi.

Task. Read an integer and print big if it is greater than 10, otherwise small.

Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.