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

Need help removing repeating lines

Status
Not open for further replies.

fsanchez13

Technical User
May 9, 2003
35
US
I have a outfile that has nothing but time stamps and I need to parse through it and just grab the first two different times I colored them in red. The actual file has many more lines of repeating time stamps but I shortend for this post. Please help!!!

23:59:34
23:59:34
23:59:34
23:59:34
23:59:34
23:59:34
23:59:34
23:59:34
23:59:34
23:59:34
23:59:34
00:29:34
00:29:34
00:29:34
00:29:34
00:29:34
00:29:34
00:29:34
00:29:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
00:59:34
01:29:34
01:29:34
01:29:34
01:29:34
01:29:34
01:29:34
01:29:34
01:29:34
 
Code:
man uniq
you can also take a look at the
Code:
 sort -u
command.

Hope This Help
PH.
 
uniq file.txt | head -2

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Or if you need the output records to be in the same order as in the original file, you could use the following awk program

awk -f fsanchez13.awk input-file

# ------ fsanchez13.awk ------
{
if ($0 != a) {
if (NR > 1) print a
a = $0
}
}
END {
if (a) print a
}

CaKiwi

&quot;I love mankind, it's people I can't stand&quot; - Linus Van Pelt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top