It seems you're doing your homework today...
grep -c "\([',]\|^$\)" filename
If by blank line you also want to include those that contain only spaces:
grep -c "\([',]\|^[[:space:]]*$\)" filename
The trick for apostrophes is to use double quotes, otherwise
''' will be an error. The construct
\( regexp1 \| regexp2 \) will match all lines that match either
regexp2. The regexp
[',] matches all lines that contain either a quote
' or a coma
Here you need to escape the parentheses
() and the pipe
| otherwise grep tries to find these characters, and don't consider them as regexp constructs. If you don't like escaping these, you can use the
-E switch (for Extended regexps) or egrep directly as:
grep -cE "([',]|^$)" filename
egrep -c "([',]|^$)" filename
In your OP you mention the
-x switch. It works to get empty lines... but will not work with your coma/quote requirement. So to match a blank line I'm using
^ is an anchor for the beginning of line and
$ is an anchor for the end of line).
Hope this helps.