## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

### Random Numbers

The Korn shell provides a special variable, RANDOM, which is used to generate random numbers in the range from 0 to 32767. It generates a different random number each time it is referenced:

```					\$ print \$RANDOM
27291
\$ print \$RANDOM
5386
\$ print \$RANDOM
6884
```

You can also initialize a sequence of random numbers by setting RANDOM to a value. Here, RANDOM is set to 7. When subsequently accessed, the values 2726 and 18923 are returned:

```					\$ RANDOM=7
\$ print \$RANDOM
2726
\$ print \$RANDOM
18923
```

When RANDOM is reset to 7 again, the same numbers are returned:

```					\$ RANDOM=7
\$ print \$RANDOM
2726
\$ print \$RANDOM
18923
```

If RANDOM is unset, the special meaning is removed, even if reset.

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required