<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?

$ grep -o ',' input.txt | wc -l
19

$ grep -c -o ',' input.txt 
10

- Jeff

-- 
GNOME.conf.au 2008: Melbourne, Australia http://live.gnome.org/Melbourne2008
 
                I get my kicks above the .sigline, sunshine.
-- 
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