# An Experiment in Randomness

You can print a random number between 1-10 with the following command.

`echo \$((( RANDOM % 10 )+1))`

## Creating random numbers

If you change it so the output is between 0-9 you get decently even results.

`cat /dev/null > random.txt && cat /dev/null > random2.txt && for ((i=0; i<=9999;i++)); do echo \$((( RANDOM % 10 ))) >> random.txt ; done && for ((i=0; i<=9;i++)); do echo \$(grep -c \$i random.txt) \$i; done  |  sort -n`

Note that you can change the command to be between 1-10, but all the 1’s in 10 will get grepped and counted as 1’s.

The above command should return something similar to the following. Sorted by lowest occurrences first.

```943 5
945 8
985 7
996 2
997 6
1005 3
1012 9
1016 4
1033 0
1068 1

We can plot them in LibreOffice Calc.

## Plot with GnuPlot

Gnuplot is another utility that you can use to plot numbers. Example is below.

``cat /dev/null > random.txt && cat /dev/null > random2.txt && for ((i=0; i<=9999;i++)); do echo \$((( RANDOM % 10 ))) >> random.txt ; done && for ((i=0; i<=9;i++)); do echo \$i \$(grep -c \$i random.txt) ; done  |  sort -n | gnuplot -p -e 'plot "/dev/stdin"'``

# wget multiple links with random access times

Create a file “list.txt” that contains all the URLs you want to download and launch the following command

`for i in `cat list.txt` ; do wget \${i} && sleep \$(( ( RANDOM % 120 ) +1 )) ; done`

It’ll now run and after each link will wait a random amount of time up to 120 seconds before downloading the next link. Change the number as needed.

# Bash random sleep timer

Change the 10 to however many seconds you need or want.

`echo \$(( ( RANDOM % 10 ) +1 ))`

Example output

```bob@localhost:~\$ echo \$(( ( RANDOM % 10 ) +1 ))
10
bob@localhost:~\$ echo \$(( ( RANDOM % 10 ) +1 ))
2
bob@localhost:~\$ echo \$(( ( RANDOM % 10 ) +1 ))
9
bob@localhost:~\$ ```

Sleep timer

`sleep \$(( ( RANDOM % 10 ) +1 ))`