random number test in bash

This commit is contained in:
2026-05-05 08:12:46 -07:00
parent f34be20aa1
commit 4c74a07eb6
2 changed files with 22 additions and 0 deletions

View File

22
bash/randTest.sh Executable file
View 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