LPIC-1 Exam 102 v5 (Linux Administrator) — Question 13
What output is produced by the following command sequence?
echo '1 2 3 4 5 6' | while read a b c; do
echo result $c $b $a;
done
Answer options
- A. result: 6 5 4
- B. result: 1 2 3 4 5 6
- C. result: 3 4 5 6 2 1
- D. result: 6 5 4 3 2 1
- E. result: 3 2 1
Correct answer: C
Explanation
The correct answer is C because the 'read' command takes the first three values from the input line, assigning them to variables a, b, and c. The output format 'result $c $b $a' results in the last three numbers in reverse order, producing 'result: 3 4 5 6 2 1'. The other options do not match this format or value arrangement.