Swap two columns – awk, sed, python, perl February 15, 2023 by Tarik You can do this by swapping values of the first two fields: awk ' { t = $1; $1 = $2; $2 = t; print; } ' input_file