Untitled Document
read Command

The read command is useful in scripts when reading or asking an input from user. This read command is used when the script want to interact with user for his inputs to contunue the script.

1. Basic Example -

Run below linux code and see how read stores the input given by user in a variable var and then prints its value using echo command .Save below code as read.ksh and run the script to see how read works .

   #!/bin/ksh 
   echo "Program to Print Values entered by user "
   echo " Enter any string , hcracter or word "
   read var 
   echo "$var"   

2. Reading multiple values with read statement

We can store multiple values entered by user using read statement . Save below code as read1.ksh and run the script to see how read works .

   #!/bin/ksh 
   echo "Program to Print Multiple strings, words enterd by user   "
   echo " Enter any 2 numbers  "
   read var1 , var2 
   echo "$var1 and $var2 "   
Untitled Document