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

Leave a comment