Feb 262010
How to sort a file by n-column
Answer:
Suppose you have a CSV file:
1,c
2,d
3,a
How do you sort by the 2nd column?
Here is the command you need:
# sort -k2 input.txt -t ','
where -t ',' mean the comma separator, and -k2 mean the 2nd column.