Created
December 27, 2015 15:42
-
-
Save jonquach/380ad98e55902fe26f47 to your computer and use it in GitHub Desktop.
Shell script for generating random number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #This script accpets two integers as argv, and generate | |
| #a random number between them included. | |
| #Author: Jonathan Quach <kwach.yami@gmail.com> | |
| if [ $# -ne 2 ]; then | |
| echo -e "Usage:\t$0 [START END]" | |
| exit | |
| fi | |
| DIFF=$(($2 - $1 + 1)) | |
| RANDOM=$$ | |
| R=$(($((RANDOM % $DIFF)) + $1)) | |
| echo $R |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment