#!/bin/bash
#string
str="string"


#number integer
int=1


#number float
float=`echo "scale=2;0.2" | bc`


#calculate
numerator=10
Denominator=3


result_str=${numerator}/${Denominator}
result_str_other=$numerator/$Denominator


result_int=$(($numerator / $Denominator)) #must be (( and ))
result_int_other=`expr $numerator / $Denominator`


result_float=`echo "scale=2;$numerator/$Denominator" | bc`
result_float_other=$(echo "scale=2;$numerator/$Denominator" | bc)


#mod
mod=`expr ${numerator} % ${Denominator}`
mod_other=$(($numerator % $Denominator))


#Addition
add=`expr $numerator + $Denominator`


#Subtraction
sub=`expr $numerator - $Denominator`


#Multiplication
mul=$((numerator * Denominator))
mul_other=`expr $numerator \* $Denominator`


#echo
echo "strting = $str"

echo "integer = $int"
echo "float = $float"


echo "result_str = $result_str"
echo "result_str_other = $result_str_other"




echo "result_int = $result_int"
echo "result_int_other = $result_int_other"


echo "result_float = $result_float"
echo "result_float_other = $result_float_other"


echo "mod = $mod"
echo "mod_other = $mod_other"


echo "add = $add"
echo "sub = $sub"
echo "mul = $mul"
echo "mul_other = $mul_other"

result


strting = string
integer = 1
float = .2
result_str = 10/3
result_str_other = 10/3
result_int = 3
result_int_other = 3
result_float = 3.33
result_float_other = 3.33
mod = 1
mod_other = 1
add = 13
sub = 7
mul = 30
mul_other = 30

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 = = 的頭像
    = =

    逗點大的雨滴

    = = 發表在 痞客邦 留言(0) 人氣()