Hi guys,
I'm trying to print the first occurence of an input line in a log file using an if statement and an index function. Check it out.
if (index($0,"MS Position Req(msgLen=23)")>0 ){
my_string = $0;
split(my_string,time,":");
substr($1,2,7);
split($1,t,":");
$1=(t[2]*60)+ t[3];
print "MS Position:",$1;
As a result all the input lines with "MS Position Req" get printed instead of the first occurence just like i wish.
Can someone help me
I'm trying to print the first occurence of an input line in a log file using an if statement and an index function. Check it out.
if (index($0,"MS Position Req(msgLen=23)")>0 ){
my_string = $0;
split(my_string,time,":");
substr($1,2,7);
split($1,t,":");
$1=(t[2]*60)+ t[3];
print "MS Position:",$1;
As a result all the input lines with "MS Position Req" get printed instead of the first occurence just like i wish.
Can someone help me