What output will the command $ seq 1 5 20 produce?

What output will the command $ seq 1 5 20 produce?

What output will the command $ seq 1 5 20 produce?

A.
1 6 11 16

B.
1 5 10 15

C.
1 2 3 4

D.
2 3 4 5

E.
5 10 15 20

Explanation/Reference:
From the man pages:
seq – seq [OPTION]… FIRST INCREMENT LAST
Print numbers from FIRST to LAST, in steps of INCREMENT.



Leave a Reply 6

Your email address will not be published. Required fields are marked *


Joe Bailey

Joe Bailey

Wrong!! The answer is E

The seq command can be useful in creating for loops (and in other ways, too): This command generates a list of numbers starting from its first argument and continuing to its last one. For instance, typing seq 1 10 generates 10 lines, each with a number between 1 and 10. You can use a for loop beginning for x in `seq 1 10` to have the loop execute 10 times, with the value of $x incrementing with each iteration. If you pass just one parameter to seq, it interprets that number as an ending point, with the starting point being 1. If you pass three values to seq, it interprets them as a starting value, an increment amount, and an ending value.

Chapter 9 – Writing Scripts, Configuring Email, and Using Databases
CompTIA Linux+ Study Guide: Exams LX0-101 and LX0-102, 2nd Edition
by Roderick W. Smith
Sybex © 2013

Micha

Micha

Well, … as you quoted.
“If you pass three values to seq, it interprets them as a starting value, an increment amount, and an ending value.
Let me quote man seq:
“seq [OPTION]… FIRST INCREMENT LAST”
“Print numbers from FIRST to LAST, in steps of INCREMENT.”

So “seq 1 5 20” would do
1 START (+5)
6 (+5)
11 (+5)
16 (+5 would be greater than 20)
and indeed let’s test it on a real linux system.

$ seq 1 5 20
1
6
11
16

Artur

Artur

Perfect. Thanks Micha!

bmcentos

bmcentos

against facts there not arguments:

➤ seq 1 5 20
1
6
11
16

alper

alper

The command required for the output on E is ‘seq 5 5 20’

:~ > seq 5 5 20
5
10
15
20

cdusrsbin

cdusrsbin

[marty@cdusrsbin ~]$ seq 0 5 100
0
5
10
15
20
25
30
35

******************************************

[marty@cdusrsbin ~]$ seq 1 5 100
1
6
11
16
21
26
31