-
Notifications
You must be signed in to change notification settings - Fork 0
/
expr.sh
executable file
·31 lines (23 loc) · 984 Bytes
/
expr.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /bin/bash
clear
echo '{{shell arithametic by expr & echo `expr op1 oprnd op2` demostraton}}'
echo `expr 3 + 3` # spaces between opr and opd is must
echo -e '\noprators that are allowed by expr'
echo " echo \`expr 1 + 1\` ; # plus oprator"
echo " result : `expr 1 + 1` "
echo " echo \`expr 6 - 1\` ; # minus oprator"
echo " result : `expr 6 - 1` "
echo " echo \`expr 6 / 2 \` ; # divide oprator"
echo " result : `expr 6 / 2` "
echo " echo \`expr 5 % 2 \` ; # mod oprator"
echo " result : `expr 5 % 2` "
echo -e 'multiply is spacial case.\nSince * in WILD CARD so /* is used instead.'
echo " echo \`expr 5 \* 2\` ; # multiply opartor with backslash "
echo " result : `expr 5 \* 2`"
echo "------------------------------------------------------"
echo "expr CAN BE USED WITH VARIALBES AND WITHIN ECHO COMMAND"
echo ">> with in stt. 10+2 = `expr 10 + 2`"
echo ">> with in stt. 10*2 = `expr 10 \* 2`"
x=" 25+25 = `expr 25 + 25`"
echo $x
echo "next PARAMETER SUBSTITUTION"