In order to achieve what you give in your example, I would suggest this:
BEGIN {FS="|"; OFS="|"; last="";}
{
if ($2 != last) {
last = $2
line++;
}
$3 =line;
print $0
}
I haven't actually tested this code, but give it a try. Part of the problem
with the old code was that it was re-setting line to zero every time the 2nd
field was the same as the previous. And then, the "line++" part was outside
the block that was controlled by the if statement, so that it was getting
incremented for every record.
--Albert
Albert Bickford
----- Original Message -----
This message has been scanned for viruses by the VEI Internet
Automatic Email Spam and Virus Scanner, and is believed to be free of spam or
viruses.
Please report spam to
spamtrap@.... If you would like 98.9 % spam blocked
from your
E-mail then go to VEI Internet for details. Anti-spam/Anti-virus is FREE with
every account.
http://www.vei.net/
mailtospamtrap@...
[Non-text portions of this message have been removed]