我需要更改列的顺序(即顺序)
# 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
这有效,但第一列后没有逗号。
# 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,
如何删除最后的逗号?有没有一种优雅的方式来做到这一点?
# 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,