- To: slug@xxxxxxxxxxx
- Subject: Re: [SLUG] Tuesday afternoon shell command optimisation party!
- From: Peter Hardy <peter@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 18 Dec 2007 17:21:35 +1100
On Tue, 2007-12-18 at 16:09 +1100, 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!
How do you want it optimised?
grep -o is the most readable. But the fastest I've found so far is
cat input.txt | tr -d '\n' | tr ',' '\n' | wc -l
--
Pete