Skip to main content
deleted 26 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 239

I am a beginner in linux. I am writing a script called pickanumber.sh. I was setting up the script so I will ask the user to pick a number. If the number that they type is not "8" than the script will continue running. I can't make the script keep running when the user picks a number other than "8". Should I use for loop or while loop? Here is the script that I have so far.

rand_num=0
let "rand_num = $RANDOM % 10 + 1"
echo $rand_num
echo -n "pick a number from 1 - 10! "
read pickanumber
if [ "$pickanumber" = "8" ]; then
   echo "GOOD JOB"
else
   read $pickanumber
fi          

I am a beginner in linux. I am writing a script called pickanumber.sh. I was setting up the script so I will ask the user to pick a number. If the number that they type is not "8" than the script will continue running. I can't make the script keep running when the user picks a number other than "8". Should I use for loop or while loop? Here is the script that I have so far.

rand_num=0
let "rand_num = $RANDOM % 10 + 1"
echo $rand_num
echo -n "pick a number from 1 - 10! "
read pickanumber
if [ "$pickanumber" = "8" ]; then
   echo "GOOD JOB"
else
   read $pickanumber
fi          

I am writing a script called pickanumber.sh. I was setting up the script so I will ask the user to pick a number. If the number that they type is not "8" than the script will continue running. I can't make the script keep running when the user picks a number other than "8". Should I use for loop or while loop? Here is the script that I have so far.

rand_num=0
let "rand_num = $RANDOM % 10 + 1"
echo $rand_num
echo -n "pick a number from 1 - 10! "
read pickanumber
if [ "$pickanumber" = "8" ]; then
   echo "GOOD JOB"
else
   read $pickanumber
fi          
edited tags; edited tags
Link
Gilles 'SO- stop being evil'
  • 866.1k
  • 205
  • 1.8k
  • 2.3k

someone please help. imI am a beginner in linux. any kind of helps i will really appreciate it. so, i haveI am writing a script called pickanumber.sh. iI was setting up the script so iI will ask the user to pick a number if. If the number that they typedtype is not "8" than the script will continue running. i cantI can't make the script keep running when the user pickpicks a number other than "8". should iShould I use for loop or while loop  ? hereHere is the script that i writeI have so far.

rand_num=0
let "rand_num = $RANDOM % 10 + 1"
echo $rand_num
echo -n "pick a number from 1 - 10! "
read pickanumber
if [ "$pickanumber" = "8" ]; then
   echo "GOOD JOB"
else
   read $pickanumber
fi          

~

someone please help. im beginner in linux. any kind of helps i will really appreciate it. so, i have writing a script called pickanumber.sh. i was setting up the script so i will ask the user to pick a number if the number that they typed is not "8" than the script will continue running. i cant make the script keep running when the user pick a number other than "8". should i use for loop or while loop  ? here is the script that i write so far.

rand_num=0
let "rand_num = $RANDOM % 10 + 1"
echo $rand_num
echo -n "pick a number from 1 - 10! "
read pickanumber
if [ "$pickanumber" = "8" ]; then
   echo "GOOD JOB"
else
   read $pickanumber
fi

~

I am a beginner in linux. I am writing a script called pickanumber.sh. I was setting up the script so I will ask the user to pick a number. If the number that they type is not "8" than the script will continue running. I can't make the script keep running when the user picks a number other than "8". Should I use for loop or while loop? Here is the script that I have so far.

rand_num=0
let "rand_num = $RANDOM % 10 + 1"
echo $rand_num
echo -n "pick a number from 1 - 10! "
read pickanumber
if [ "$pickanumber" = "8" ]; then
   echo "GOOD JOB"
else
   read $pickanumber
fi          
formatting text
Source Link
Ipor Sircer
  • 14.9k
  • 2
  • 31
  • 44
Loading
Source Link
Loading