Please help me to get required output for both scenario 1 and scenario 2 and need separate code for both scenario 1 and scenario 2
Scenario 1
i need to do below changes only when column1 is CR and column3 has duplicates rows/values. This inputfile can contain 100 of this duplicated rows of column3 Value in column 3 to be suffixe with sequence starting from "a" followed by CR.
if we have appended suffix till a to z with CR like(aCR, bCR, cCR till zCR), then next suffix will be aaCR, abCR, acCR ans so on for column3
Input File
a||c
CR||2157237496
CR||2157237496
CR||2157237496
INV||2157237496
RNV||3457634589
Output File
a||c
CR||2157237496aCR
CR||2157237496bCR
CR||2157237496cCR
INV||2157237496
RNV||3457634589
Scenario 2 Required separate code for this scenario Below is for different file i need to do below changes only when column1 is DR and column3 has duplicates rows/values.
Value in column 3 to be suffixe with sequence starting from "a" except for first document followed by DR.
if we have appended suffix till a to z with DR like(aDR, bDR, cDR till zDR), then next suffix will be aaDR, abDR, acDR ans so on for column3
Input File
a||c
DR||3770022521
DR||3770022521
DR||3770022521
INV||9876543738
output file
a||c
DR||3770022521
DR||3770022521aDR
DR||3770022521bDR
INV||9876543738
I tried below code, it is giving me output for scenario 2 but not able to append sequence number to column3. I am able to suffix only "a" which is static. Here need to consider column1 equal to CR for scenario 1 and DR for scenario2 as well(that im unable to do)
awk -F"|" -v OFS="|" '{if(++a[$3]>1)$3=$3"a"}1' d1.txt
Code output :
a||c
CR||2157237496
CR||2157237496a
CR||2157237496a
INV||2157237496a
RNV||3457634589
Please help me to get required output for both scenario 1 and scenario 2 and need separate code for both scenario 1 and scenario 2