commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
It takes a byte from /dev/random whose source is the kernel entropy pool (better source than other solutions).
This is /bin/sh compatible.
If X is 5, it will about a number between 1 and 5 inclusive.
This works in bash and zsh.
If you want between 0 and 4, remove the +1.