I have a pipe-delimited file with 24 fields. It is sorted on the 24th field. I need a program (or command, awk, nawk, whatever) that will go record-by-record, and flag every record where the 24th field is the same as the previous record AND field 19 is DIFFERENT (from the previous record). Maybe flag those records with a 'Y'. Flag all other records with an 'N', perhaps. So, my file looks like this:
Record1||||||||||||||||||AAAAA|||||0001
Record2||||||||||||||||||AAAAA|||||0001
Record3||||||||||||||||||BBBBB|||||0002
Record4||||||||||||||||||BBBBB|||||0002
Record5||||||||||||||||||CCCCC|||||0002
Record6||||||||||||||||||DDDDD|||||0003
Record7||||||||||||||||||EEEEE|||||0003
And I would like to have ouput like this (or something close to it):
Record1||||||||||||||||||AAAAA|||||0001|N
Record2||||||||||||||||||AAAAA|||||0001|N
Record3||||||||||||||||||BBBBB|||||0002|N
Record4||||||||||||||||||BBBBB|||||0002|N
Record5||||||||||||||||||CCCCC|||||0002|Y
Record6||||||||||||||||||DDDDD|||||0003|N
Record7||||||||||||||||||EEEEE|||||0003|Y
I'm sure this is probably a simple loop, but I can't figure it out... Can anyone help me out here? Thanks in advance!
Record1||||||||||||||||||AAAAA|||||0001
Record2||||||||||||||||||AAAAA|||||0001
Record3||||||||||||||||||BBBBB|||||0002
Record4||||||||||||||||||BBBBB|||||0002
Record5||||||||||||||||||CCCCC|||||0002
Record6||||||||||||||||||DDDDD|||||0003
Record7||||||||||||||||||EEEEE|||||0003
And I would like to have ouput like this (or something close to it):
Record1||||||||||||||||||AAAAA|||||0001|N
Record2||||||||||||||||||AAAAA|||||0001|N
Record3||||||||||||||||||BBBBB|||||0002|N
Record4||||||||||||||||||BBBBB|||||0002|N
Record5||||||||||||||||||CCCCC|||||0002|Y
Record6||||||||||||||||||DDDDD|||||0003|N
Record7||||||||||||||||||EEEEE|||||0003|Y
I'm sure this is probably a simple loop, but I can't figure it out... Can anyone help me out here? Thanks in advance!