Free LPI 102-500 Actual Exam Questions - Question 1 Discussion
echo ‘1 2 3 4 5 6’ | while read a b c; do
echo result $c $b $a;
done
E, because read only assigns the first three numbers and then stops.
B tbh, I see why E seems right, but the ‘read a b c’ will actually assign a=1, b=2, and c=3 and then the loop echoes those three in reverse order once. The leftover numbers (4 5 6) don’t get processed in this setup because read reads one line at a time, and there’s only one line. So output is “result 3 2 1” just once, which matches E, not B. The command doesn’t print the whole set or reverse all six numbers, so options like B or D don’t make sense here.
E imo, since read only takes the first three values into a, b, and c, the output is just “result 3 2 1” once. The rest of the numbers get ignored because the loop runs a single time.
Actually, the loop runs once, reading only three values, so E fits perfectly.
Maybe E, because only first three numbers get read and printed reversed once.
It’s E. Since read assigns 1, 2, and 3 to a, b, c, the output reverses those three values only once; the rest of the numbers don’t get processed.
Probably E, since read takes only first three words, loop runs once.
E The read command grabs only the first three values into a, b, c, so the output is “result 3 2 1” exactly once. The rest of the numbers are ignored since it’s a single line input.
E The read command splits the line into just three variables, so only 1, 2, 3 go to a, b, c respectively. The echo reverses those and prints “result 3 2 1” once.
It’s E for sure. The read command with three vars will only assign the first three numbers to a, b, and c, then the while loop only runs once since all input is on one line. So it prints result 3 2 1. The other numbers (4 5 6) don’t get read into variables or cause another loop iteration.
Yeah, E looks good since read stops after the first three values, so output is “result 3 2 1”.
Actually, I’d say it’s E because the read command with three variables only assigns the first three inputs: a=1, b=2, c=3. The rest (4 5 6) aren’t assigned anywhere. Then echo prints result $c $b $a, which gives “result 3 2 1.” The while loop just runs once since there’s only one line of input. So options A, B, C, and D can’t be right since they show more numbers or reversed order beyond those three values.
This one’s definitely E since read only assigns the first three values to a, b, c, ignoring the rest. The echo then prints them reversed: 3 2 1.
It’s E because read only takes the first three values into a, b, and c. The rest (4 5 6) are ignored, so the output is just "result 3 2 1" as in option E.
It’s E because the read command splits the input into three variables, so only 1, 2, and 3 are used, then echo prints them in reverse order as shown.
Option E, since only first three values read and printed reversed once.
Not E, it’s actually E reversed. The read command assigns 1 to a, 2 to b, and 3 to c, so echo prints result 3 2 1 once since there's only one line.
It’s E because read only takes the first three words, so output reverses those.
It’s E, read splits into a=1, b=2, c=3 and prints reversed.