Swap columns in a text file

I have a space delimited text file where I want to swap first and second columns (i.e. first column becomes second and the second column becomes first). How do I go about doing that? Thanks.

Your time might be better spent learning awk than asking many questions that are trivial to solve in it.

awk '{ t=$1 ; $1=$2; $2=t; print }' inputfile > outputfile
sed 's/\([^ ]*\)[ ][ ]*\([^ ]*\)/\2 \1/' inputfile
while read a b c
do
   echo $b $a $c
done <inputfile