On Dec 18, 2007 4:53 PM, Jeff Waugh <[EMAIL PROTECTED]> wrote:
> <quote who="James Gray">
>
> >> Not the most graceful, but the following seems to work:
> >>        grep -o ',' input.txt |wc -l
> >
> > Assuming we're using GNU "grep" we can leave the pipe off:
> >     grep -c -o ',' input.txt
>
> Hmm, unfortunately the -c misinterprets the count due to a weird interaction
> between -c and -o. I wonder if this should be regarded as a bug in GNU grep?
>

Not a bug at all! grep -c only counts the number of matching lines,
not the number of occurances of a pattern in a line.

Lindsay

-- 
http://slug.org.au/ (the Sydney Linux Users Group)
http://holmwood.id.au/~lindsay/ (me)
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to