-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
Description:
Sir we can use double bracket for arithmetic operation in bash is more flexible way because it doesn't matter if there is a bracket or not. So I'm kindly suggesting to replace / include this double bracket guide.
Suggested Labels:
Improvement
Suggested Assignees:
Affected Product Version:
OS, DB, other environment details and versions:
Steps to reproduce:
Related Issues:
Current Code:
#!/bin/sh
A=70
B=90
val=`expr $A + $B` #Be Mindful about the spaces in between the "expr" , $A , + , $B characters,
# which is a must. Otherwise script will throw a syntax error
echo "A + B : $val"
val=`expr $A - $B`
echo "A - B : $val"
val=`expr $A \* $B`
echo "a * b : $val"
val=`expr $B / $A`
echo "B / A : $val"
val=`expr $B % $A`
echo "B % A : $val”Suggesting Code
#!/usr/bin/bash
A=70
B=90
((val = $A + $B))
echo "A + B : $val"
((val=$A-$B))
echo "A - B : $val"
((val= $A * $B))
echo "a * b : $val"
((val = $B / $A))
echo "B / A : $val"
((val= $B % $A))
echo "B % A : $val"Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels