PrepAway - Latest Free Exam Questions & Answers

What output will the following command sequence produce?

What output will the following command sequence produce?
echo ‘1 2 3 4 5 6’ | while read a b c; do echo result: $c $b $a; done

PrepAway - Latest Free Exam Questions & Answers

A.
result: 3 4 5 6 2 1

B.
result: 1 2 3 4 5 6

C.
result: 6 5 4

D.
result: 6 5 4 3 2 1

E.
result: 3 2 1

Explanation:

2 Comments on “What output will the following command sequence produce?

  1. Mahoni says:

    the first word is assigned to the first name, the second word to the second name, and so on, with leftover words and their intervening separators assigned to the last name

    In this case, a is assigned the value 1, b is assigned the value 2, and c gets the rest of the line “3 4 5 6”. Then print out c (3 4 5 6), then b (2), then a (1), giving you output you see.

    The loop isn’t doing anything in this case, since there’s only a single line to read from your first echo.

    🙂




    5



    0

Leave a Reply