Specific question - bad title I am trying to sort a set of CSV data like -
2014/06/04 13:19:06.970,1124,Post Request,200,OK,text,true,,782,1,0
2014/06/04 13:18:27.241,237,Post Request,200,OK,text,true,,303,1,0
2014/06/04 13:12:15.973,2224,Post Request,200,OK,text,true,,1551,1,0
2014/06/04 13:12:31.365,238,Post Request,204,No Content,,true,,237,1,0
2014/06/04 13:12:29.892,1429,Post Request,204,No Content,,true,,237,1,0
using -
sort -t"," -k2,3
The result is
2014/06/04 13:19:06.970,1124,Post Request,200,OK,text,true,,782,1,0
2014/06/04 13:18:27.241,1429,Post Request,200,OK,text,true,,303,1,0
2014/06/04 13:12:15.973,2224,Post Request,200,OK,text,true,,1551,1,0
2014/06/04 13:12:31.365,237,Post Request,204,No Content,,true,,237,1,0
2014/06/04 13:12:29.892,238,Post Request,204,No Content,,true,,237,1,0
But I want something like -
2014/06/04 13:19:06.970,237,Post Request,200,OK,text,true,,782,1,0
2014/06/04 13:18:27.241,238,Post Request,200,OK,text,true,,303,1,0
2014/06/04 13:12:15.973,1124,Post Request,200,OK,text,true,,1551,1,0
2014/06/04 13:12:31.365,1429,Post Request,204,No Content,,true,,237,1,0
2014/06/04 13:12:29.892,2224,Post Request,204,No Content,,true,,237,1,0
or reverse of this (actually reverse is better for me). What am I doing wrong?
Add
-n
to have it sorted numerically:Or reverse with
-r
:From
man sort
: