I dont know how can I generate random answer.

exemple result:

user:~$ ./question.sh do you love me ?
user:~$ yes


user:~$ ./question.sh do you hate me ?
user:~$ maybe

I try to put all the String in a variable like :

d='yes','no','maybe' etc..
but the message errors is always : impossible : not found
  • 1
    Traditionally, when folks have a problem they want help with, they post their code, which I don't see here. Please click edit and add the contents of question.sh so we may provide assistance.
    – K7AAY
    Mar 29, 2019 at 16:04

1 Answer 1


array=( yes no maybe )
read -p 'do you hate me ? [press a key] >>> '
echo ${arr[RANDOM % ${#array[@]}]}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.