LFCS · Question #551
Which of the following outputs 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 argument N, prints numbers from 1 to N, 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 though 9 with one number per line.
- DThe number 10 to standard output.
How the community answered
(24 responses)- B88% (21)
- C4% (1)
- D8% (2)
Why each option
The `seq` command, when given a single argument `N`, prints numbers from 1 to `N`, each on a new line.
This describes a continuous process, not the discrete output of `seq`, and `seq` does not default to increments of 10.
The `seq` command generates sequences of numbers. When invoked with a single argument, it defaults to starting at 1, incrementing by 1, and ending at the specified number. Therefore, `seq 10` will output the integers from 1 to 10, each on its own line.
The `seq` command defaults to starting at 1, not 0, when only an end number is provided.
This only outputs the final number; `seq` generates a sequence from the start to the end value.
Concept tested: Linux `seq` command usage
Source: https://linux.die.net/man/1/seq
Topics
Community Discussion
No community discussion yet for this question.