Shell Scripting Tutorial – 5

Hello,

expr is similar to let except instead of saving the result to a variable it instead prints the answer. Unlike let you don’t need to enclose the expression in quotes. You also must have spaces between the items of the expression. It is also common to use expr within command substitution to save the output to a variable.

 

Code:

#!/bin/bash

expr 5 + 10

expr 20 \* 5

a=$( expr 10 – 3 )
echo $a

expr $1 + 30

 

Video: https://www.youtube.com/watch?v=5_AOCX5W4KE

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s