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
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
not logical to me, but anyway:
echo $a=1
echo $b=2
echo $c=3 4 5
Explanation:
a=1
b=2
c=3 4 5 6 (3 and the remainder over for a last variable).
$c (3456) $b (2) $c(1) == 3 4 5 6 2 1
thanks for the explanation alex
[root@mini ssh]# echo ‘1 2 3 4 5 6’ | while read a b c; do
> echo result: $c $b $a;
> done
result: 3 4 5 6’ 2 ‘1