Reputation: 8182
I have a file that starts with strings as follows
x1, 1, 2, ...
x2, 1, 2, ...
x10, 1, 3, ...
x22, 1, 3, ...
x14, 1, 2, ...
Is is possible to sort this file using awk, so that I get the output that is numerically sorted, e.g. lines starting with x1, followed by x2,.. and so on ?
Upvotes: 0
Views: 1307
Reputation: 3360
If, like Dennis said, your prefix is of fixed width, try using:
sort -k 1.2 -g -t,
In my case, using the sort that came with Mac OS X, I had to use the -g
switch.
Upvotes: 1