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

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

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:



Leave a Reply 2

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


Mahoni

Mahoni

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.

🙂