Linux Administration
medium
Pregunta de Linux Administration #019e3987
Enunciado de la Pregunta
Linux Administration
#seq
#number-sequence
#increment
#default-start
Medio
What output will the command seq 10 produce?
A
A continuous stream of numbers increasing in increments of 10 until stopped.
B
The numbers 1 through 10 with one number per line.
Correcto
C
The numbers 0 through 9 with one number per line.
D
The number 10 to standard output.
Explicación Oficial / Explicaciones de la Comunidad
The seq command in Linux generates a sequence of numbers. By default, without any flags, seq starts at 1, increments by 1, and ends at the specified last number. The output is one number per line.
How it Works
seq 10is equivalent toseq 1 1 10(start=1, increment=1, end=10).- It prints numbers from 1 to 10 inclusive, each on a separate line.
- The command does not produce a continuous stream; it outputs all numbers and then exits.
Why the Correct Answer is Right
The output of seq 10 is exactly the numbers 1 through 10, one per line. This is the default behavior of seq.
Why the Incorrect Answers are Wrong
- A continuous stream of numbers increasing in increments of 10 until stopped: This describes an infinite loop or a command like
yesorwatch, notseq.seqalways terminates after printing the specified sequence. - The numbers 0 through 9 with one number per line: This would be the output of
seq 0 9orseq 9if counting from 0, butseqdefaults to starting at 1, not 0. - The number 10 to standard output: This would be the output of
echo 10orseq 10 10, butseq 10prints all numbers from 1 to 10, not just the last one.
After issuing: