LFCS · Question #1
What output will the following command produce? seq 1 5 20
The correct answer is A. 1. The seq command with three arguments generates a sequence of numbers starting from the first argument, incrementing by the second argument, and stopping at or before the third argument.
Question
Options
- A1
- B1
- C1
- D2
- E5
How the community answered
(32 responses)- A88% (28)
- C6% (2)
- D3% (1)
- E3% (1)
Why each option
The `seq` command with three arguments generates a sequence of numbers starting from the first argument, incrementing by the second argument, and stopping at or before the third argument.
The command `seq 1 5 20` starts the sequence at 1, increments each subsequent number by 5, and generates numbers up to a maximum of 20. Therefore, the first number produced in this sequence is 1.
Option D suggests the sequence starts with 2, but the `seq` command explicitly defines the starting number as the first argument, which is 1.
Option E suggests the sequence starts with 5, but 5 in the `seq 1 5 20` command represents the increment value, not the starting value.
Concept tested: Linux `seq` command syntax
Source: https://www.gnu.org/software/coreutils/manual/html_node/seq-invocation.html
Topics
Community Discussion
No community discussion yet for this question.