⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 int-or-string.sh

📁 Shall高级编程
💻 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 + -