help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Counting words, fast!


From: Jesse Hathaway
Subject: Re: Counting words, fast!
Date: Wed, 17 Mar 2021 10:37:08 -0500

On Wed, Mar 17, 2021 at 7:07 AM Greg Wooledge <greg@wooledge.org> wrote:
> One might argue that when writing a shell script, the POSIX utilities
> are the "standard library".  They are *meant* to be used.  The shell's
> built-in feature set is severely limited *because* it's designed to
> use these tools to do the heavy lifting.

For sure there is an argument to be made, but a shell example was already
provided[1]:

tr 'A-Z' 'a-z' | tr -s ' ' '\n' | LC_ALL=C sort -S 2G | uniq -c | sort -nr

So I thought it would be fun to try a version just using Bash with no external
programs.

[1]: https://github.com/benhoyt/countwords/blob/master/optimized.sh



reply via email to

[Prev in Thread] Current Thread [Next in Thread]