Archive

Posts Tagged ‘text processing’

Swapping columns in a text file

September 22, 2007 1 comment

An awk snippet to swap columns in a text file:

awk -F'[ ]' '{ print $2, ": ", $1 }' original.txt >swapped.txt

The '[ ]' is the separator in the original file (a regular expression). The ": " is the separator that is put in the result file.

You can also be done with cut and paste command line tools.

Follow

Get every new post delivered to your Inbox.