0

I have a text file on Linux server Centos 7 which include a lot of entries in the following format:

Test Test, 1234567890123456, a, b, cde

and I would like to reorder this to the correct the format:

1234567890123456, a, b, cde, Test Test
1
$ awk 'BEGIN { FS = ", *"; OFS = ", " } { print $2, $3, $4, $5, $1 }' file
1234567890123456, a, b, cde, Test Test

The awk script starts by defining the input field separator (FS) to be a comma followed by any number of spaces, and the output field separator (OFS) to be a comma and a space.

It then goes on to simple output the input fields in the correct order.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.