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

Grep for the same occurrence or maybe Sed ?

Status
Not open for further replies.

gfunk123

IS-IT--Management
May 22, 2001
143
GB
Hi, I have a file that looks like this


dasdjasdjoasjdoasjdoa SYN dakspodkapsdka
asdasdasdasdasdasdasd SYN sdfsdfsdfsdfdf
shfishifhsdifhsidhfif fsdfsdfsdfsdfs
sdfsdfsdfsdsdfsdfsdff cercercercerce
sdasdajsdoajsodasodoo FIN dasdaskdpasdda
dkaspdkaskdpaskpaskdp FIN asdasdasdasdas

dasdjasdjoasjdoasjdoa SYN dakspodkapsdka
asdasdasdasdasdasdasd SYN sdfsdfsdfsdfdf
shfishifhsdifhsidhfif fsdfsdfsdfsdfs
sdfsdfsdfsdsdfsdfsdff cercercercerce
sdasdajsdoajsodasodoo FIN dasdaskdpasdda
dkaspdkaskdpaskpaskdp FIN asdasdasdasdas


The file is a huge log file wit always 2 lines with SYN in exactly the same place on after the other, and also 2 FINS together. We have discovered that we are getting errors where 3 SYN lines are togeter, and I want to identify where these occurences are ie

dasdjasdjoasjdoasjdoa SYN dakspodkapsdka
asdasdasdasdasdasdasd SYN sdfsdfsdfsdfdf
asdasdasdasdasdasdasd SYN sdfsdfsdfsdfdf
shfishifhsdifhsidhfif fsdfsdfsdfsdfs
sdfsdfsdfsdsdfsdfsdff cercercercerce
sdasdajsdoajsodasodoo FIN dasdaskdpasdda
dkaspdkaskdpaskpaskdp FIN asdasdasdasdas

Ive looked at using grep to search for '3 SYNS' but i cant seem to get it to work.

Does anybody know how i can search for an occurrence of SYN in the same place , three lines running

Any help would be greatly appreciated
 
AWK way: nawk -f countTWOS.awk myLogFile.txt

#------------------ countTWOS.awk -----------------------

BEGIN {
field=2;
}

{
arr[$field]++;


for (i in arr)
if (i != $field)
arr=0;

if (arr[$field] > 2)
printf("Line->[%d] Field->[%s] Count->[%d]\n", FNR, $field, arr[$field]);
}


vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top