Read User Inputs from Keyboard

#! /bin/bash
echo Enter your name  : 
read name
echo Entered name is $name
echo ---------------------------------------------------------------------
echo Enter 3 friends name  : 
read name1 name2 name3
echo Entered names are $name1 $name2 $name3
echo ---------------------------------------------------------------------
read -p "Enter your best friends name inline : " best_friend # p flag for print
echo Your best friends name is $best_friend
echo ---------------------------------------------------------------------
read -sp "Enter your password : " pass_var # s flag for silent i.e not show password
echo #echo with no string to come to next line \n
echo ---------------------------------------------------------------------
echo "Store names in an Array"
read -a names # a flag stands for Array
echo Name : ${names[0]}, ${names[1]}
echo ---------------------------------------------------------------------
echo "Store name in built in variable called reply"
read # by default the value is store in built in variable called reply
echo The value is $REPLY

Leave a Comment