Scott Ragen wrote:

I have to disagree. Whilst it may be fast, its not 100% correct.
Most of the time it would probably work, but if there are any blank lines, it outputs the current count, and starts again.

Consider the following file contents:
--file contents--
this,is,the,first,line
this,is,the,second

the,above,was,a,blank,line

and,another,blank,line
--end file contents--

On Jeff's original command:
sed 's#[^,]*##g' input.txt | tr -d '\n' | wc -m
15

The perl command:
perl -00 -ne 'print tr/,//' input.txt
753

Change the input line separator to octal 0777:

perl -0777 -ne 'print tr/,//' input.txt
15


cheers
rickw



--
_________________________________
Rick Welykochy || Praxis Services

People who enjoy eating sausage and obey the law should not watch either being 
made.
    -- Otto von Bismarck
--
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