Extract lines from a log-file with duplicate fields?
- From: "Duncan Smith" <DSmith1974@xxxxxxxxxxxxxx>
- Date: 19 Mar 2007 11:09:40 -0700
How could I extract all of the lines from a log-file which have a
certain field duplicated?
For example, if File1.log contained
1,1,Fixed
2,2,Geared
3,1,Indexed
4,4,Hub
5,4,Freewheel
6,4,STI
Using any common GNU utilities like sed/awk/uniq/tac/egrep (not Perl
though), let's say I need a command that will return all lines where
the second field is duplicated. Note that the duplicated field may or
may not be in consecutive lines. So, I need to end up with;
1,1,Fixed
3,1,Indexed
4,4,Hub
5,4,Freewheel
6,4,STI
For added points I could also do with a count of the number of times
the field was repeated (next to the field itself):
Field 1 repeated 2
Field 4 repeated 3
or even just:
1,2
4,3
Any thoughts?
Many thanks,
Duncan.
.
- Follow-Ups:
- Re: Extract lines from a log-file with duplicate fields?
- From: Ed Morton
- Re: Extract lines from a log-file with duplicate fields?
- From: Chris F.A. Johnson
- Re: Extract lines from a log-file with duplicate fields?
- From: Janis Papanagnou
- Re: Extract lines from a log-file with duplicate fields?
- From: OldSchool
- Re: Extract lines from a log-file with duplicate fields?
- Prev by Date: correct escaping of sed and tr commands in ksh script?
- Next by Date: Re: Extract lines from a log-file with duplicate fields?
- Previous by thread: correct escaping of sed and tr commands in ksh script?
- Next by thread: Re: Extract lines from a log-file with duplicate fields?
- Index(es):
Relevant Pages
|