I have a csv file with fields delimited by ";". There are 8 fields, and I want to sort my data by the first 4 columns, in increasing order (first sort by column 1, then column 2, etc)
How I can do this from a command line in linux?
I tried with open office, but it only lets me select 3 columns.
EDIT: among the fields on which I want to sort my data, three fields contain strings with numerical values, one only strings. How can I specify this with the sort
command?
sort -k
will allow you to define the sort key. Fromman sort
:So
should do it. Note that I've escaped the semi-colon, otherwise the shell will interpret it as an end-of-statement.
Try:
eg: