I am trying to add the number of occurance in the last column of a pipe delimited file based on column 1, 2 and 3.
I have tried awk '{ print $0 "|" ++count[$1,$2,$3] }'
But it is producing just number 1 in the last column in all the rows adding an additional pipe as below
123|456365|PASS|566563|Apple||1
123|456365|PASS|566563|Apple||1
123|456365|FAIL|34322|Apple1||1
123|456365|FAIL|35322|Apple2||1
It would be very helpful if someone can help me out to get it working to get the expected output below.
Input file
123|456365|PASS|566563|Apple
123|456365|FAIL|34322|Apple1
123|456365|FAIL|35322|Apple2
123|456335|PASS|56655|Apple34
123|456335|FAIL|34325|Apple53
123|34343|PASS|35323|Apple1
123|34343|PASS|34342|Apple13
123|34343|PASS|343442|Apple13
Expected output
123|456365|PASS|566563|Apple|1
123|456365|FAIL|34322|Apple1|1
123|456365|FAIL|35322|Apple2|2
123|456335|PASS|56655|Apple34|1
123|456335|FAIL|34325|Apple53|1
123|34343|PASS|35323|Apple1|1
123|34343|PASS|34342|Apple13|2
123|34343|PASS|343442|Apple13|3