我不知道如何生成随机答案。
结果示例:
user:~$ ./question.sh do you love me ?
user:~$ yes
或者
user:~$ ./question.sh do you hate me ?
user:~$ maybe
我尝试将所有字符串放入变量中,例如:
d='yes','no','maybe' etc..
but the message errors is always : impossible : not found
答案1
#!/bin/bash
array=( yes no maybe )
read -p 'do you hate me ? [press a key] >>> '
echo ${arr[RANDOM % ${#array[@]}]}