#!/bin/awk -f { if (NF>2){ temp=$1; $1=$2; $2=temp; } for (i=1;i<=NF;i++){ printf("%s ",$i) } printf("\n"); }