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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get uniq hour:minute lines 1

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
0
0
PL
The text file contains:

2008-02-26 18:06:00 s1 2.03
2008-02-26 18:06:01 s1 1.95
2008-02-26 18:11:00 s1 2.02
2008-02-26 18:11:01 s1 2.02
2008-02-26 18:16:00 s1 1.97
2008-02-26 18:21:00 s1 1.92
2008-02-26 18:21:01 s1 3.05
2008-02-26 18:26:00 s1 3.77
2008-02-26 18:26:01 s1 3.71
2008-02-26 18:31:01 s1 2.63
2008-02-26 18:36:00 s1 2.51
2008-02-26 18:36:01 s1 2.79
2008-02-26 18:41:00 s1 2.31


I need to process it and get uniq lines for HH:MM (seconds should be ignored).

So, I expect in result:

2008-02-26 18:06:00 s1 2.03
2008-02-26 18:11:00 s1 2.02
2008-02-26 18:16:00 s1 1.97
2008-02-26 18:21:00 s1 1.92
2008-02-26 18:26:00 s1 3.77
2008-02-26 18:31:01 s1 2.63
2008-02-26 18:36:00 s1 2.51
2008-02-26 18:41:00 s1 2.31

Thank you in advance.
 
[tt]

Perhaps ...
awk '!a[substr($2,1,5)] {print; ++a[substr($2,1,5)]}' data
2008-02-26 18:06:00 s1 2.03
2008-02-26 18:11:00 s1 2.02
2008-02-26 18:16:00 s1 1.97
2008-02-26 18:21:00 s1 1.92
2008-02-26 18:26:00 s1 3.77
2008-02-26 18:31:01 s1 2.63
2008-02-26 18:36:00 s1 2.51
2008-02-26 18:41:00 s1 2.31
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top