How do I read a value from user input into a variable

Justin picture Justin · Jul 23, 2011 · Viewed 39.6k times · Source

In ksh, how do I prompt a user to enter a value, and load that value into a variable within the script?

command line

echo Please enter your name: 

within the script

$myName = ?

Answer

Marcus Borkenhagen picture Marcus Borkenhagen · Jul 23, 2011

You want read:

echo Please enter your name:
read name
echo $name

See read(1) for more.