[CONTACT]

[ABOUT]

[POLICY]

If you are bored on

Found at: republic.circumlunar.space:70/~katolaz/phlog/20190202_roulette.txt

   If you are bored on a Unix shell...   
=========================================

Well, to be honest, you should never ever get bored in the Unix
environment. But if your mood happens to border boredom, then the
following one-liner will help you:

  $ export d="/usr/share/man/man1/"
  $ man ${d}/$(ls $d | tail -n +$(echo "$(od -An -N2 -i /dev/random) % $(ls -f $d | wc -l) + 1" | bc ) | head -1)

Just try to run the second command a couple of times. If you are more
into programming, you might like to replace "man1" with "man3" on the
first line (which just needs to be run once).

The interesting part of the one-liner is probably:

  od -An -N2 -i /dev/random

which reads two bytes from `/dev/random` and returns an integer between
0 and 65535. Then bc(1) does the rest, and it is really awesome at that.
We'll probably say more about bc(1), head(1) and tail(1) at some point
in the future. You can probably put the one-liner in a shell script
called `teachme` ;)

    "I am never bored; to be bored is an insult to
    one's self."  -- Jules Renard

  -+-+-+-
man(1) and od(1) appeared in UNIXv1 (1971)
bc(1) appeared in UNIXv6 (1975)
tail(1) appeared in UNIXv7 (1979)
head(1) appeared in BSD2.x (ca 1979-1980)


AD: