To capture input from the user, the read command is used to assign the characters entered on the command line to a variable:


echo Please enter your name
read name
echo Hi $name, nice to meet you!


Multiple values may also be read:


echo Please enter your fist and last names
read first last
echo Hi $first of the $last family, nice to meet you!


Use the -a option to instruct read to store the words in to an indexed array.


echo Please enter a phrase
read -a myvar

for i in ${myvar[*]}
echo $i