SLUG Mailing List Archives
Re: [SLUG] Tuesday afternoon shell command optimisation party!
- To: slug@xxxxxxxxxxx
- Subject: Re: [SLUG] Tuesday afternoon shell command optimisation party!
- From: Rick Welykochy <rick@xxxxxxxxxxxxx>
- Date: Wed, 19 Dec 2007 00:17:53 +1100
- User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:184.108.40.206) Gecko/20070802 SeaMonkey/1.1.4
Jamie Wilkinson wrote:
This one time, at band camp, Jeff Waugh wrote:
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
Rick Welykochy || Praxis Services
People who enjoy eating sausage and obey the law should not watch either being made.
-- Otto von Bismarck