nerdexam
CompTIA

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.

Shells, Scripting and Data Management

Question

Which of the following outputs will the below command produce? seq 1 5 20

Options

  • A1
  • B1
  • C1
  • D2
  • E5

How the community answered

(18 responses)
  • A
    89% (16)
  • B
    6% (1)
  • D
    6% (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.

A1Correct

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.

B1

This choice is identical to A, and without further context on how the output is represented, A is chosen as the first correct one.

C1

This choice is identical to A, and without further context on how the output is represented, A is chosen as the first correct one.

D2

The sequence starts from 1, not 2, as specified by the `FIRST` argument of the `seq` command.

E5

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

#seq command#shell utilities#command output

Community Discussion

No community discussion yet for this question.

Full LX0-104 Practice