LX0-104 · Question #279
Which of the following outputs will the below command produce? seq 1 5 20
The correct answer is A. 1. The command seq 1 5 20 generates a sequence of numbers starting from 1, with an increment of 5, and stops at or before 20.
Question
Options
- A1
- B1
- C1
- D2
- E5
How the community answered
(18 responses)- A89% (16)
- B6% (1)
- D6% (1)
Why each option
The command `seq 1 5 20` generates a sequence of numbers starting from 1, with an increment of 5, and stops at or before 20.
The `seq` command with three arguments `FIRST INCREMENT LAST` generates numbers starting at `FIRST`, adding `INCREMENT` to each subsequent number, and stopping when the next number would exceed `LAST`. For `seq 1 5 20`, the numbers generated are 1, 6, 11, and 16, as 16 + 5 = 21, which is greater than 20.
This choice is identical to A, and without further context on how the output is represented, A is chosen as the first correct one.
This choice is identical to A, and without further context on how the output is represented, A is chosen as the first correct one.
The sequence starts from 1, not 2, as specified by the `FIRST` argument of the `seq` command.
The sequence starts from 1, not 5, and the increment is 5, meaning 5 would not be the first number unless FIRST was 5.
Concept tested: `seq` command usage and arguments
Source: https://man7.org/linux/man-pages/man1/seq.1.html
Topics
Community Discussion
No community discussion yet for this question.