LX0-104 · 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 generates a sequence of numbers. When given a single argument, it defaults to producing numbers from 1 up to that argument, with each number 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
(50 responses)- A2% (1)
- B92% (46)
- C4% (2)
- D2% (1)
Why each option
The seq command generates a sequence of numbers. When given a single argument, it defaults to producing numbers from 1 up to that argument, with each number on a new line.
seq generates a finite sequence based on its arguments, not a continuous stream, and seq 10 does not specify an increment of 10.
The seq command, when provided with a single positive integer argument N, outputs a sequence of numbers starting from 1 up to and including N, with each number printed on a separate line, using a default increment of 1. Therefore, seq 10 will output numbers 1, 2, ..., 10.
By default, seq starts from 1, not 0.
seq produces a sequence of numbers, not just the final number.
Concept tested: Generating number sequences with seq command
Source: https://linux.die.net/man/1/seq
Topics
Community Discussion
No community discussion yet for this question.