Wednesday, July 25, 2018

Swap columns in text file with awk

To swap column 2 and 3 in a 4 column file:
awk -F, '{print $1,$3,$2,$4}' OFS=; "FILE" > NEW_FILE
where:

OFS: indicates the separator character(';' in the example above).
FILE: original file.
NEW_FILE: new file with the changes.

Related Posts:

0 comments:

Post a Comment

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

Search This Blog

Powered by Blogger.