-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 You got the name wrong, but your are right about how to use it. :) It needs an integer argument. As you can see my little 2 liner does not even check to see that you pass it an integer.
I actually got this from faq.org. There is a ton of neat stuff there. sgrover wrote: > That ain't workin for me... That's always returning zero. > > Ok, I figured it out if you call your script "myrandom", then you need > to do "./myrandom 25" (to generate a number between 1 and 25. > > You could also just do "echo $((RANDOM % 25 + 1))" at the command line, > and bypass the script altogether. Just replace the 25 with upper limit > you need, and the 1 with the lower limit. > > Any scripters want to whip up a script that will ask for the upper limit > , and then produce a random number and prompt if another should be done > (or quit). Basically keep spitting out random numbers when the user > asks for one, until they say they've had enough... :) > > Shawn > > > Gustin Johnson wrote: > > For the next meeting, here is a script that will generate a random > number between 1 and a number that you specify as input. > > #!/bin/bash > > rnumber=$((RANDOM%$1+1)) > echo $rnumber >> _______________________________________________ clug-talk mailing list [email protected] http://clug.ca/mailman/listinfo/clug-talk_clug.ca Mailing List Guidelines (http://clug.ca/ml_guidelines.php) **Please remove these lines when replying > _______________________________________________ > clug-talk mailing list > [email protected] > http://clug.ca/mailman/listinfo/clug-talk_clug.ca > Mailing List Guidelines (http://clug.ca/ml_guidelines.php) > **Please remove these lines when replying -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGTAhFwRXgH3rKGfMRAlOVAKCXig8AIU62djXn+mWYoGoSwz6HzACeLbxF TaCFPX/Ny3VASqENnWTDH84= =izuq -----END PGP SIGNATURE----- _______________________________________________ clug-talk mailing list [email protected] http://clug.ca/mailman/listinfo/clug-talk_clug.ca Mailing List Guidelines (http://clug.ca/ml_guidelines.php) **Please remove these lines when replying

