2022-06-14
- Ecriture d'un readme d'utilisation Jmeter
- bash script prompt (y/n) ? From Bash ScriptGo to text ā
Basic in line method
read -p "Is this a good question (y/n)? " answer case ${answer:0:1} in y|Y ) echo Yes ;; * ) echo No ;; esacI prefer to use
caseso I could even test foryes | ja | si | ouiif needed...In line with single key feature
Under bash, we can specify the length of intended input for for the
readcommand:read -n 1 -p "Is this a good question (y/n)? " answerUnder bash,
readcommand accepts a timeout parameter, which could be useful.read -t 3 -n 1 -p "Is this a good question (y/n)? " answer [ -z "$answer" ] && answer="Yes" # if 'yes' have to be default choice