🚀 Code smarter. Crack exams faster. Free AI-powered learning on Leyaa.ai →

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



🚀 Code smarter. Crack exams faster.

90+ interactive coding courses & 200+ competitive exam prep — powered by learning intelligence. All free.

Try Leyaa.ai Now →

Topics You Might Like