Search a string in a text file and add another string at the end of line

Dear All

I am having a text file which is having more than 200 lines.

EX:

       001010122    12000 BIB 12000 11200  1200003  
       001010122    2000  AND 12000 11200  1200003 
       001010122    12000 KVB 12000 11200  1200003 

In the above file i want to search for string KVB and add another string BANK at the end of line (or some 150th position of line)

Result

       001010122    12000 BIB 12000 11200  1200003  
       001010122    2000  AND 12000 11200  1200003 
       001010122    12000 KVB 12000 11200  1200003    BANK

Please help

awk '/KVB/ {$0=$0" BANK"} 1' file

PS Use code tags

1 Like

thanks

using printf

sed '/KVB/ s/$/BANK/' file
awk '/KVB/ {$0=sprintf("%-150s %s\n",$0,"BANK")} 1' file