CompTIA Linux+ Powered by LPI (LX0-104) — Question 1
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
Answer options
- 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
Correct answer: A
Explanation
The command uses a while loop to read three variables from the input, assigning them as a, b, and c. Since the input is '1 2 3 4 5 6', the last three numbers assigned to c, b, and a are 3, 4, and 5 respectively, resulting in 'result: 3 4 5 6 2 1' as the output. The other options do not match this order or content.