Linux Know-How provides a collection of introductory texts on often needed Linux skills.


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


Last Update: 2010-12-16