LFCS · Question #117
What output will the command seq 10 produce?
The correct answer is B. The numbers 1 through 10 with one number per line. The seq command, when given a single positive integer, prints a sequence of numbers from 1 up to that integer, each on a new line.
Question
Options
- AA continuous stream of numbers increasing in increments of 10 until stopped.
- BThe numbers 1 through 10 with one number per line.
- CThe numbers 0 through 9 with one number per line.
- DThe number 10 to standard output.
How the community answered
(26 responses)- A4% (1)
- B92% (24)
- D4% (1)
Why each option
The `seq` command, when given a single positive integer, prints a sequence of numbers from 1 up to that integer, each on a new line.
`seq` produces a finite sequence defined by its arguments, not a continuous stream, and the default increment is 1, not 10.
When `seq` is invoked with a single argument, it interprets it as the final value (last). By default, it starts from 1 and increments by 1, printing each number on a new line until the last value is reached. Thus, `seq 10` will output numbers 1, 2, 3, ..., 10, each on its own line.
`seq` starts counting from 1 by default when only an end value is provided, not 0.
`seq 10` generates a sequence up to 10, not just the single number 10.
Concept tested: `seq` command usage
Source: https://man7.org/linux/man-pages/man1/seq.1.html
Topics
Community Discussion
No community discussion yet for this question.