How can I generate random answer string like "yes,no,maybe maybe not? The Next CEO of Stack OverflowWhich are the standard commands available in every Linux based distribution?How to efficiently generate large, uniformly distributed, random integers in bash?How to get binary representations of strings in Shell?The best way to add Unix Shell variables to CURL GET requestHow to list only JPEG files from root below using the command line?How to generate a random string?iptables: does making use of -m conntrack increase system load?wall forces everyone to input something to get back to the promptRunning script through ssh and evaluate some var/comand inside the host machineSed Fails to store the result into a variable
Is it professional to write unrelated content in an almost-empty email?
Touchpad not working on Debian 9
Is it convenient to ask the journal's editor for two additional days to complete a review?
Does destroying a Lich's phylactery destroy the soul within it?
Expectation in a stochastic differential equation
Decide between Polyglossia and Babel for LuaLaTeX in 2019
"Eavesdropping" vs "Listen in on"
Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?
How to find image of a complex function with given constraints?
How to use ReplaceAll on an expression that contains a rule
Won the lottery - how do I keep the money?
Help/tips for a first time writer?
Is a distribution that is normal, but highly skewed, considered Gaussian?
Easy to read palindrome checker
Is it ok to trim down a tube patch?
Reshaping json / reparing json inside shell script (remove trailing comma)
Film where the government was corrupt with aliens, people sent to kill aliens are given rigged visors not showing the right aliens
Getting Stale Gas Out of a Gas Tank w/out Dropping the Tank
What does "shotgun unity" refer to here in this sentence?
Is it ever safe to open a suspicious HTML file (e.g. email attachment)?
Is fine stranded wire ok for main supply line?
Can I calculate next year's exemptions based on this year's refund/amount owed?
Purpose of level-shifter with same in and out voltages
Can Sneak Attack be used when hitting with an improvised weapon?
How can I generate random answer string like "yes,no,maybe maybe not?
The Next CEO of Stack OverflowWhich are the standard commands available in every Linux based distribution?How to efficiently generate large, uniformly distributed, random integers in bash?How to get binary representations of strings in Shell?The best way to add Unix Shell variables to CURL GET requestHow to list only JPEG files from root below using the command line?How to generate a random string?iptables: does making use of -m conntrack increase system load?wall forces everyone to input something to get back to the promptRunning script through ssh and evaluate some var/comand inside the host machineSed Fails to store the result into a variable
I dont know how can I generate random answer.
exemple result:
user:~$ ./question.sh do you love me ?
user:~$ yes
or
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
linux shell-script terminal string
add a comment |
I dont know how can I generate random answer.
exemple result:
user:~$ ./question.sh do you love me ?
user:~$ yes
or
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
linux shell-script terminal string
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
2 days ago
add a comment |
I dont know how can I generate random answer.
exemple result:
user:~$ ./question.sh do you love me ?
user:~$ yes
or
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
linux shell-script terminal string
I dont know how can I generate random answer.
exemple result:
user:~$ ./question.sh do you love me ?
user:~$ yes
or
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
linux shell-script terminal string
linux shell-script terminal string
edited 2 days ago
Rui F Ribeiro
41.8k1483142
41.8k1483142
asked 2 days ago
ZPUFF19ZPUFF19
84
84
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
2 days ago
add a comment |
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
2 days ago
1
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
2 days ago
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
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
#!/bin/bash
array=( yes no maybe )
read -p 'do you hate me ? [press a key] >>> '
echo $arr[RANDOM % $#array[@]]
Also see stackoverflow.com/questions/13888735/… and codegolf.stackexchange.com/questions/157546/…
– K7AAY
2 days ago
add a comment |
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f509450%2fhow-can-i-generate-random-answer-string-like-yes-no-maybe-maybe-not%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
#!/bin/bash
array=( yes no maybe )
read -p 'do you hate me ? [press a key] >>> '
echo $arr[RANDOM % $#array[@]]
Also see stackoverflow.com/questions/13888735/… and codegolf.stackexchange.com/questions/157546/…
– K7AAY
2 days ago
add a comment |
#!/bin/bash
array=( yes no maybe )
read -p 'do you hate me ? [press a key] >>> '
echo $arr[RANDOM % $#array[@]]
Also see stackoverflow.com/questions/13888735/… and codegolf.stackexchange.com/questions/157546/…
– K7AAY
2 days ago
add a comment |
#!/bin/bash
array=( yes no maybe )
read -p 'do you hate me ? [press a key] >>> '
echo $arr[RANDOM % $#array[@]]
#!/bin/bash
array=( yes no maybe )
read -p 'do you hate me ? [press a key] >>> '
echo $arr[RANDOM % $#array[@]]
edited 2 days ago
answered 2 days ago
Gilles QuenotGilles Quenot
16.4k14053
16.4k14053
Also see stackoverflow.com/questions/13888735/… and codegolf.stackexchange.com/questions/157546/…
– K7AAY
2 days ago
add a comment |
Also see stackoverflow.com/questions/13888735/… and codegolf.stackexchange.com/questions/157546/…
– K7AAY
2 days ago
Also see stackoverflow.com/questions/13888735/… and codegolf.stackexchange.com/questions/157546/…
– K7AAY
2 days ago
Also see stackoverflow.com/questions/13888735/… and codegolf.stackexchange.com/questions/157546/…
– K7AAY
2 days ago
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f509450%2fhow-can-i-generate-random-answer-string-like-yes-no-maybe-maybe-not%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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
2 days ago