Linux

  1. Home
  2. Computing & Technology
  3. 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 Linux

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Linux

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

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

All rights reserved.