?? int-or-string.sh
字號:
#!/bin/bash# int-or-string.sh: Integer or string?a=2334 # Integer.let "a += 1"echo "a = $a " # a = 2335echo # Integer, still.b=${a/23/BB} # Substitute "BB" for "23". # This transforms $b into a string.echo "b = $b" # b = BB35declare -i b # Declaring it an integer doesn't help.echo "b = $b" # b = BB35let "b += 1" # BB35 + 1 =echo "b = $b" # b = 1echoc=BB34echo "c = $c" # c = BB34d=${c/BB/23} # Substitute "23" for "BB". # This makes $d an integer.echo "d = $d" # d = 2334let "d += 1" # 2334 + 1 =echo "d = $d" # d = 2335echo# What about null variables?e=""echo "e = $e" # e =let "e += 1" # Arithmetic operations allowed on a null variable?echo "e = $e" # e = 1echo # Null variable transformed into an integer.# What about undeclared variables?echo "f = $f" # f =let "f += 1" # Arithmetic operations allowed?echo "f = $f" # f = 1echo # Undeclared variable transformed into an integer.# Variables in Bash are essentially untyped.exit 0
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -