I need to change the sequence of the columns (i.e. order)
# cat customer.csv
customerno, firstname, lastname, sales
23242, john, doe, 2345.00
23253, jane, doe, 1234.00
23221, greg, johnson, 2345.00
23210, howard, gardner, 2345.00
This works, but there is no comma after first column.
# awk '{print $4, $3, $2, $1}' customer.csv
sales lastname, firstname, customerno,
2345.00 doe, john, 23242,
1234.00 doe, jane, 23253,
2345.00 johnson, greg, 23221,
2345.00 gardner, howard, 23210,
How do I remove the comma at the end? Is there an elegant way of doing this?
# awk '{print $4 ",", $3, $2, $1}' customer.csv
sales, lastname, firstname, customerno,
2345.00, doe, john, 23242,
1234.00, doe, jane, 23253,
2345.00, johnson, greg, 23221,
2345.00, gardner, howard, 23210,
You were close, you just forgot to set your field separators: