For a pure bash solution (however, it's bash-specific): If $x is the variable containing your string:
expr length "$x2="${x//[^\"]/}"
echo ${#x2}
The ${x// thing removes all chars except ", expr length${#x2} then countscalculates the characterslength of the resulting stringthis rest.
(Original suggestion using expr which has problems, see comments: )
expr length "${x//[^\"]/}"