Plz Help in sorting the data on date basis

I have file a.txt having below data

cat a.txt

01-MAY-13 2.38.11.00.100089 IN 4512 0000741881
01-JUN-13 2.38.11.00.100089 IN 1514 0000764631
01-NOV-13 2.38.11.00.100089 IN 1514 0000856571
01-NOV-13 2.38.15.00.100015 IN 300.32 0000856531
01-JUN-13 2.38.19.00.100000 IN 2698 0000764493
01-JUL-13 2.38.19.00.100000 IN 2850.14 0000768996
01-NOV-13 2.38.19.00.100000 IN 2698 0000856493
sort -n -k a.txt

but it is not working

i want to sort the above data on date basis and my output should be as below

01-MAY-13	2.38.11.00.100089	IN	4512	0000741881
01-JUN-13	2.38.19.00.100000	IN	2698	0000764493
01-JUN-13	2.38.11.00.100089	IN	1514	0000764631
01-JUL-13	2.38.19.00.100000	IN	2850.14	0000768996
01-NOV-13	2.38.19.00.100000	IN	2698	0000856493
01-NOV-13	2.38.11.00.100089	IN	1514	0000856571
01-NOV-13	2.38.15.00.100015	IN	300.32	0000856531

Please help

Thanks in advance.

Try

for considering only month

$ sort -t-  -k2M  file

01-MAY-13 2.38.11.00.100089 IN 4512 0000741881
01-JUN-13 2.38.11.00.100089 IN 1514 0000764631
01-JUN-13 2.38.19.00.100000 IN 2698 0000764493
01-JUL-13 2.38.19.00.100000 IN 2850.14 0000768996
01-NOV-13 2.38.11.00.100089 IN 1514 0000856571
01-NOV-13 2.38.15.00.100015 IN 300.32 0000856531
01-NOV-13 2.38.19.00.100000 IN 2698 0000856493

this considers day - mon - year

$ sort -t- -k3 -k2M -nk1  file
1 Like

Try

sort -t- -nk3 -k2M -nk1  file
1 Like

@ranabhavish please use codetag for data also..

1 Like

This same discussion was also started and answered here.

Ok, i will follow this next time, as i was new to this that's why this happened.
Thanks