QuestionQ33

VerifiedEssential Commands

What output does the following command sequence produce?

echo '1 2 3 4 5 6' | while read a b c; do  
echo result: $c $b $a;  
done  
Explanation

With more input fields than variables, read assigns the first fields to a and b and assigns all remaining fields to the final variable, c. Therefore the variables expand in the order c, b, a as 3 4 5 6, 2, and 1.

Community Discussion

No comments yet. Be the first to start the discussion!