-
Shell ArithmeticIoT 과정 2017. 7. 6. 11:06반응형
Creating Inter Variables
number=123.45 // type : local string
integer counter=12 // type : local integer
typeset -i total=32767
exort total // type : export integer
integer minimum=-2147483648 // type : local integerBase10 and Others
typeset -i int_num=10 //value string: 10
typeset -i2 bin_num=10 //value string: 2#1010
typeset -i8 oct_num=10 //value string: 8#12
typeset -i16 hex_num=10 //value string: 16#aWorking with Arithmetic
let x=4+5 // ((x=4+5))
let "x= 4 + 5" // (( x = 4 + 5 ))
print $((x=4+5)) --> 9
print $x ---> 9Binary Operators
<< shift bits left (( 8 << 1 )) --> 16 // 1000 10000
>> shift bits right (( 8 >> 1 )) --> 4 // 1000 100
& bitwise AND (( a & b )) ---> // 1000 & 0100 = 0000
| bitwise OR (( a | b )) ----> // 1000 & 0110 = 1110
^ bitwise exclusive OR (( a^b )) ----> // 1000 & 1110 = 0110Working with Numeric Data
awk : UNIX command/program language
bc : Desktop calculator
expr : Expression command with functions
$(#string) : Length of string variable contents
PPID : Integer number of parents process
RANDOM : Random integer
SECONDS : Elapsed secons반응형'IoT 과정' 카테고리의 다른 글
Shell Patterns (0) 2017.07.07 Branches and Logic Testing (0) 2017.07.06 Shell Arithmetic (0) 2017.07.06 Designing Program Output (0) 2017.07.06 User Input (0) 2017.07.05 Variable (0) 2017.07.05