How to print number of i occurrences in Pneumonoultramicroscopicsilicovolcanoconiosis ?
I dont know how to approach this with the commands grep and wc
CodePudding user response:
This should do it:
echo "Pneumonoultramicroscopicsilicovolcanoconiosis"|tr -cd 'i'| wc -c
CodePudding user response:
echo "Pneumonoultramicroscopicsilicovolcanoconiosis" | grep -o i | wc -l
CodePudding user response:
$ echo "Pneumonoultramicroscopicsilicovolcanoconiosis" | awk '{print gsub(/i/,"")}'
6