Reputation: 1616
I have the following file which looks something like this:
XYZ,3498384,2006-04-25_12:32:45,WXZ
ABC,3498384,2006-04-25_12:33:57,DEF
NNN,3498384,2006-04-25_12:33:57,MMMM
GGGG,3874499,2006-04-25_21:14:16,TTTT
JJJJ,2518173,2006-04-25_15:12:30,PPPP
I have read many answers but none of them were able to sort this file. Can one suggest how should I do it?
These are the question that I have checked :
Sort command in not working properly in unix for sorting a csv file
But I wasn't able to understand how to use it awk
for my problem.
Any help would be useful.
Upvotes: 0
Views: 613
Reputation: 247012
Because you are using a sensible timestamp format, you can simply use lexical sorting:
sort -t, -k3,3 file
Upvotes: 2