PrepAway - Latest Free Exam Questions & Answers

6 Comments on “What output will the command $ seq 1 5 20 produce?

  1. Joe Bailey says:

    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




    0



    3
    1. Micha says:

      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




      4



      0

Leave a Reply