Read a number in shell script

In Shell Script, we can read number using read keyword.




Syntax

read name



Example

#read number in shell script

echo "Enter a Number"
read num

echo "Number = $num"

To print the value of the variable, we need to specify the '$' symbol before the variable name.




Output

Enter a Number

10

Number = 10


Enter a Number

100

Number = 100



Topics You Might Like