The read Command
When writing shell programs, the user may require entering a few input/data from the keyboard and assigning it to the shell variables. The read command allow this
Syntax
read variablename
The read command waits for the user for enter a value. The shell assigns in which value to the shell variable that is specified through variable name.
Practice 1
The following program describes the usage of the read command.
# cat > read
echo "enter the name:"
read name
echo "$name Welcome to the world of Unix environment"
# sh read
enter the name Sunil
Sunil welcome to the world of Unix environment
The given program will interact with the user and get the name Sunil from the user through the keyboard and alternate the name and display the message Sunil Welcome to Unix Environment.