Suppose that a file looks like:
a|b|c|d
a|b|c|d
...
a|b|c|d
How do I transpose two fields, for example:
c|b|a|d
c|b|a|d
...
c|b|a|d
Thanks in advance!
Here is another solution: swap the first and third field, then print:
awk -F '|' '{ temp=$1; $1=$3; $3=temp; print }' data.txt
At least if memory serves, something on this general order should work:
BEGIN { FS="|"; }
{ printf("%s|%s|%s|%s\n", $3, $2, $1, $4); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With