LFCS practice question 15 of 35

What output will the command seq 10 produce?

Full set: 260 questions
Answer options
A: A continuous stream of numbers increasing in increments of 10 until stopped.
B: The numbers 1 through 10 with one number per line. Correct answer
C: The numbers 0 through 9 with one number per line.
D: The number 10 to standard output.
Correct Answer:
B. The numbers 1 through 10 with one number per line.
Explanation

The seq command is a standard utility for printing a sequence of numbers to standard output. When invoked with a single argument, LAST, it defaults to a starting value of 1 and an increment of 1. Therefore, seq 10 will print the sequence of numbers from 1 up to and including 10. By default, each number in the sequence is separated by a newline character, resulting in one number per line.

Why Incorrect

A. A continuous stream of numbers increasing in increments of 10 until stopped: seq produces a finite sequence and the default increment is 1, not 10.
C. The numbers 0 through 9 with one number per line: The default starting number for seq is 1, not 0.
D. The number 10 to standard output: seq prints the entire sequence from the starting number to the final number, not just the final number.

References

- GNU Coreutils Manual, Section 20.1 "seq: Print a sequence of numbers". The documentation states, "Print numbers from FIRST to LAST, in steps of INCREMENT. If FIRST is omitted, it defaults to 1. ... If only one argument is given, seq prints all numbers from 1 to that number."

- man seq page from the Linux man-pages project. The synopsis seq [OPTION]... LAST and seq [OPTION]... FIRST LAST confirms that a single argument is interpreted as the last number in a sequence starting from 1.

Scroll to Top