Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to sort times

Status
Not open for further replies.

kismet

MIS
Mar 5, 2003
24
PH
How can I sort time records chronologically?
Given that a file contains:
10:30a ...
08:30a ...
11:00p ...
09:15a ...
01:30p ...
...

how do I make them into the ff. (arranged chronologically)? I've tried the sort -n command, but obviously it just looks at the time itself and not the "a" or "p" mark and sorts the record according to the numbers.

Thank you!
 
With your posted example:
Code:
....+....1....+....2
   10:30a ...
you can try something like this:
Code:
sort -t'µ' -k 1.9,1.9 -k 1.4,1.8
The -t option argument can be any character not appearing in the input file.

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top