Sorting on date basis


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sorting on date basis
# 1  
Old 11-12-2013
Sorting on date basis

I have file data.txt having below data


cat data.txt
Code:
01-MAY-13 2.38.11.00.100089 IN 4512 0000741881
01-MAY-13 2.38.11.00.100089 IN 4512 0000741881
01-JUN-13 2.38.11.00.100089 FC 1514 0000764631
01-NOV-13 2.38.11.00.100089 FC 1514 0000856571
01-NOV-13 2.38.11.00.100089 IN 300.32 0000856531
01-MAY-13 2.38.11.00.100089 FC 4512 0000741881
01-JUL-13 2.38.19.00.100000 FC 2698 0000764493
01-NOV-13 2.38.19.00.100000 IN 2698 0000856493
01-JUL-13 2.38.19.00.100000 IN 2850.14 0000768996

Code:
sort -n -k a.txt

but it is not working

i want to sort the above data on first date basis (first column) and IN should be preference on FC and my output should be as below

cat data.txt
Code:
01-MAY-13 2.38.11.00.100089 IN 4512 0000741881
01-MAY-13 2.38.11.00.100089 IN 4512 0000741881
01-MAY-13 2.38.11.00.100089 FC 4512 0000741881
01-JUN-13 2.38.11.00.100089 FC 1514 0000764631
01-JUL-13 2.38.19.00.100000 IN 2850.14 0000768996
01-JUL-13 2.38.19.00.100000 FC 2698 0000764493
01-NOV-13 2.38.11.00.100089 IN 300.32 0000856531
01-NOV-13 2.38.11.00.100089 FC 1514 0000856571
01-NOV-13 2.38.19.00.100000 IN 2698 0000856493

Please help

Thanks in advance

Last edited by Don Cragun; 11-12-2013 at 03:57 AM.. Reason: Fix CODE tags.
# 2  
Old 11-12-2013
Moderator's Comments:
Mod Comment This is the third time this message has been posted. Several methods were given in the other two threads to help you sort your data. Asking the same question again and ignoring the earlier responses does not help. This thread is closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To search the pattern on the basis of date and exit code

Hi, I am getting scheduler log file on daily basis from windows box which contains job status and corresponding date, date is in windows format. I wanted to write one script which will search the pattern (Exit code) for the today's date and if code is Zero then Job Success message should be... (14 Replies)
Discussion started by: ajju
14 Replies

2. Shell Programming and Scripting

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... (5 Replies)
Discussion started by: ranabhavish
5 Replies

3. UNIX for Dummies Questions & Answers

Plz Help in sorting the data on date basis

I have file having below data 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 Replies)
Discussion started by: ranabhavish
2 Replies

4. Shell Programming and Scripting

Sorting by date

I am trying to sort by two columns. The first column in an ID, the second is a date in the form yyyy-mm-dd. I need to sort by the ID column, then in ascending order for the date column (earliest date to most recent date compared to today). Input data: 012-abc 2012-04-25 ... (3 Replies)
Discussion started by: mollydog11
3 Replies

5. Shell Programming and Scripting

Group on the basis of common text in the square bracket and sorting

File A 99 >ac >ss >juk 70 >acb >defa 90 >ca 100 >aa >abc >bca 85 >cde 81 >ghi >ghij 87 >def >fgh <ijk 89 >fck >ghij >kill >aa The given output shud be 100 >aa >abc >bca 87 >def >fgh <ijk 89 >fck >ghij >kill >aa (2 Replies)
Discussion started by: cdfd123
2 Replies

6. Shell Programming and Scripting

send an e-mail on the date basis

one of the script is writing as fallow . certification authority - exprire on July 16, 2056 How to send an e-mail to an e-mail id say abc@gmail.com one month before the expire date. Thanks (1 Reply)
Discussion started by: nagendramv
1 Replies

7. Shell Programming and Scripting

sorting of files on the basis of timestamp

Hi, With the help of below script im able to get the count of all the .xml files but that count is not specific to a day ie its the total count of all .xml files what i want is specific to 1 day and that of every half an hr ie from 23 feb 2009 7 am till 23rd feb 2009 2300 am and from 07:00 to... (1 Reply)
Discussion started by: ss_ss
1 Replies

8. UNIX for Dummies Questions & Answers

date sorting

Hi at all, I have to sort a log file on timestamp field. That's field is the third! a log file sample..... 1|EVTVOD-1-20060709_000614|2006/07/09-0:11:23|0.3.8 1|EVTVOD-1-20060709_000614|2006/07/09-0:11:16|0.3.8 1|EVTVOD-1-20060709_000614|2006/07/09-0:11:20|0.3.8... (3 Replies)
Discussion started by: nmilella
3 Replies

9. UNIX for Dummies Questions & Answers

sorting on date

I have a file where dates in the form mm/dd/yyyy is the first field. How do I sort the file by the date field? Thanks, Duckman (6 Replies)
Discussion started by: Duckman
6 Replies
Login or Register to Ask a Question