If I have a file something like as shown below,
ARM*187878*hjhj
BAG*88778*jjjj
COD*7777*kkkk
BAG*87878*kjjhjk
DEF*65656*89989*khjkk
I need the line numbers to be added with a colon when it matches the string "BAG". Here in my case, I need something like
ARM*187878*hjhj
2:BAG*88778*jjjj
COD*7777*kkkk
4:BAG*87878*kjjhjk
DEF*65656*89989*khjkk
I can use this
awk '{print FNR ":" $0}'
for getting the line numbers. Can anyone advise how to fetch based on the beginning of s string