random number test in bash
This commit is contained in:
22
bash/randTest.sh
Executable file
22
bash/randTest.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# set script restart
|
||||
script=$(readlink -f "$0")
|
||||
|
||||
# Select number
|
||||
echo "Pick a number:"
|
||||
read num
|
||||
|
||||
# Output response
|
||||
echo "The random number is $((1 + $RANDOM % $num))."
|
||||
|
||||
# Ask to run again
|
||||
|
||||
echo "Run script again (yes/no)?"
|
||||
read answer
|
||||
if [ "$answer" = yes ]
|
||||
then exec "$script"
|
||||
fi
|
||||
echo "Exiting"
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user