Re: OT How to count occurances in a text file buck <buck@private.mil> wrote:
>
>
> Can you please help me determine where there are unmatched quotes (")
> in my .mailfilterrc file?
>
> grep -c returns the number of lines where the " appears, but I need
> something that counts the number of instances of " per line.
>
> Something like
>
> while read LINE; do
> count how many times " occurs in this line
> if count=0 then ignore # Skip zero and
> if count<>2 then echo $LINE # two; show all others
> done <.mailfilterrc
>
> TIA, I'm crosseyed looking at 377 lines :<
> buck
Hi,
maybe the thing to do is to look for lines with a single " first
using regular expressions with grep, and if that doesn't uncover
your problem, then look for 3 or more.
Maybe something like the following:
grep -e '^[^\"]*\"[^\"]*$' filename
grep -e '^[^\"]*\"[^\"]*\"[^\"]*\"' filename
Cheers,
Rob Komar |