|
Nifty shell script of the day: calculating standard deviation
If you find yourself working on the command line and need to whip out a quick statistical analysis or two, you'll be glad to know that Wicked Cool Shell Scripts fan Josh Kotecha has sent in a very nice little shell script that does just that using the scriptbc script included in the book.
Here's his script, as written: #!/bin/sh # copyright(c) j. kotecha 2004 -- http://www.vidia.com/ # this file may be used without fee as long as the copyright # notice is kept the program is is "as is" and not warranted # for any purpose. Use at your own risk M="0" s="0" v="0" d="0" if [ $# -eq 0 ]; then exit 1 fi if [ $1 = "-m" ]; then M=$2 shift 2 else M=0 fi list=$* count=$# for i in $* do d=`scriptbc -p 9 $i - $M` v=`scriptbc -p 9 $d \* $d` s=`scriptbc -p 9 $s + $v` done std="`scriptbc -p 9 $s / $count`" std="`scriptbc -p 9 sqrt \( $std \)`" echo $stdThe script itself could be fine-tuned a bit, but the important thing to see here is that Wicked Cool Shell Scripts really does enable readers to get more out of the command line and shell scripting environment, to create scripts and commands that they otherwise wouldn't have been able to create. Great job, Josh!
Categorized:
Shell Script Programming
(Article 3695,
Written by Dave Taylor)
Tagged: Previous: And on my doorstep today: "Creating Cool Web Sites with HTML, XHTML and CSS" Next: Changes in the login shell from Jaguar to Panther Subscribe!
Rather amazingly, there are no comments on this article yet.
I have something to say, now that you mention it, but ...
I do have a comment, now that you mention it!
|
Recommended
Recent Entries
Search
I Need Help!
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and RSS Feeds Building Web Site Traffic Business and Management CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above Facebook Help Google Plus Help HTML and CSS Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Mac OS X Help Pay Per Click (PPC) Advertising Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help WordPress Help |