Jason Gooner Jason Gooner - 1 year ago 133
Bash Question

Random number from a range in a Bash Script

I need to generate a random port number between

from a shell script. The problem is
is only a 16-bit number, so I'm stuck!

would work nicely if it wasn't for the size limitation.

Does anyone have an example of how I can do this, maybe by extracting something from
and getting it within a range?

Answer Source
shuf -i 2000-65000 -n 1


Edit: The range is inclusive.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download