Gestione input con read

From RVM Wiki
Revision as of 17:55, 29 June 2006 by Gabriele.vivinetto (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Per leggere una stringa da STDIN in bash, usare il comando read.

man bash
/       read \[

Esempio: Premere un tasto per continuare:

#!/bin/bash
read -n1 -p"Si o No ? " RISP
echo -e "\n"
if [[ ("$RISP" == "s" || "$RISP" == "S") ]]; then
    echo Hai scelto Si
else
    Hai scelto no o qualcosaltro
fi