1. Home
  2. Computing & Technology
  3. Focus on Linux

Linux Newbie Administrator Guide

From Authors, for About.com

8.2.14 Extra tools

yes

Generate a never-ending output of strings containing "yes" (it does end when <Ctrl><c> is pressed or when electricity goes off). Sounds like a silly utility, but it can be used to write simple programs on the command line. For example, the following amusing on-liner determines the frequency of digits in 100 000 random numbers (the whole command is a single line):

yes | sed '100000q' | awk 'BEGIN{srand() ;u=6*log(10)}{printf"%e\n",rand()*exp(rand()*u)}'| cut -c1 | sort | uniq -c

I hope this example does not scare you too much--it surely shows that the old-fashioned UNIX command line can be as complicated (and powerful) as you wish to make it. If you are interested why the frequency of digits varies (it seems intuitively that it is should be constant if the numbers are random), try the website from which I borrowed the example: http://www.newscientist.com/ns/19990731/letters4.html

* License

* Linux Newbie Administrator Guide Index

Explore Focus on Linux

More from About.com

  1. Home
  2. Computing & Technology
  3. Focus on Linux
  4. Linux Documentation
  5. Newbie Administrator Guide
  6. Linux Newbie Administrator Guide - 8.2 Simple Programming under Linux

©2008 About.com, a part of The New York Times Company.

All rights reserved.