I have a data like this, fixed number of characters in every line(8)
RYRYRYRR
YRRRRYRR
YYRRRRRY
RYYRRRRR
RRRRRRRY
RYRRRRRY
I need output count the number of “Y” and “R” separately as shown below..
RYRYRYRR 3 5
YRRRRYRR 2 6
YYRRRRRY 3 5
I’ve tried a script using grep as shown below..
grep -c ‘Y’test.dat which is printing some number like 13
Try this:
In awk, gsub returns the number of successful substitutions.