Read user input in Bash shell scripting
Read command is of the most used command in Bash shell scripting, it useful for read the data from input devices.
simple example for read user input data from below.
#!/bin/bash
echo "Enter name : "
read name
echo "entered name : $name"
echo "Enter name : "
read name
echo "Enter place : "
read place
echo "Enter phone : "
read phone
echo "entered name : $name"
echo "entered name : $place"
echo "entered name : $phone"
here,when we run this script, it will ask for "Enter Name:" after entered name, it stores in $name here echo is used to print output like "Entered name is 7hills".
simple example for read user input data from below.
#!/bin/bash
echo "Enter name : "
read name
echo "entered name : $name"
echo "Enter name : "
read name
echo "Enter place : "
read place
echo "Enter phone : "
read phone
echo "entered name : $name"
echo "entered name : $place"
echo "entered name : $phone"
here,when we run this script, it will ask for "Enter Name:" after entered name, it stores in $name here echo is used to print output like "Entered name is 7hills".
Comments
Post a Comment