I need to print the count of a matching string at the end of each line.
An example for matching foo:
foo,bar,foo,foo
bar,foo,bar,bar
foo,foo,bar,bar
Result :
foo,bar,foo,foo,3
bar,foo,bar,bar,1
foo,foo,bar,bar,2
I have checked this link(How to count the number of a specific character in each line?) but no luck.