Sem 3‎ > ‎OS (Unix) LAB‎ > ‎

D4: echo

posted Oct 9, 2011, 3:15 AM by Neil Mathew   [ updated Oct 9, 2011, 3:26 AM ]
It is used to display text on screen.

Syntax:

echo "<text>"

Example: 

echo "Sum of 5 numbers = $sum"

$ echo "HELLO"
HELLO

Mistakes:


No plus needed.

echo "Enter 5 numbers: "
read a
read b
read c
read d
read e

sum=`      expr $a + $b + $c + $d + $e `

echo "The Sum is:" + $sum"


OUTPUT:

Enter 5 numbers:
3
4
5
6
7
The Sum is: + 25

When displaying variables, it matters not whether they are in double quotes or not. 


echo "The Sum is:" $sum


Enter 5 numbers:
2
3
4
5
6
The Sum is: 20



Comments