Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] Tuesday afternoon shell command optimisation party!


Jamie Wilkinson wrote:
This one time, at band camp, Jeff Waugh wrote:
Hi all,

Here's a starting point. What's a more optimal way to perform this task? :-)

 sed 's#[^,]*##g' input.txt | tr -d '\n' | wc -m

Tuesday afternoon shell optimisation party!

You want to count the total number of characters in a file, not including
newlines, that are on lines that don't start with a comma.

Does it have to be in shell? :-)

How about this. You want to count the total number of commas in a file.

python -c "import sys; print (''.join(sys.stdin.readlines())).count(',')" < input.txt

cheers
rickw


--
_________________________________
Rick Welykochy || Praxis Services

People who enjoy eating sausage and obey the law should not watch either being made.
    -- Otto von Bismarck