shell中各種奇怪的符號整理

2021-08-30 11:35:14 字數 763 閱讀 5352

()      子shell中執行

(()) 數值比較,運算,支援正則 ((i=1;i<=3;i++)) ,((commond1 && commond2))

$() 命令替換=> `commond`

$(()) 支援運算 $((1+2))

{} 集合,可將命令與字串隔開 $%

${} 變數的引用

檔案測試,數值比較,檔案比較,字串比較 [ -a ]且,[ -o ]或

增加了對正則的支援,[[ =~ ]]包含,[[ || ]]或,[[ && ]]且

$ 支援變數運算 $[2**2]=>2^2 => $[var1**var2]

//簡單的例子

[root@mysql-master scripts]# var1=2

[root@mysql-master scripts]# var2=10

[root@mysql-master scripts]# echo $[2**10]

1024

[root@mysql-master scripts]# echo $

bash: $: bad substitution

[root@mysql-master scripts]# echo $[var1+var2]

12[root@mysql-master scripts]# echo $

var2

[root@mysql-master scripts]#

(2 8)shell中各種奇怪的符號

usr bin bash read p please input number num num3 123yy num3 0 9 echo 表示 num3變數是否匹配後面的正則模式,表示 如果不是數字,就echo 1 while true do if num 0 9 then 後面是正則比較,不要加 ...

整理的shell指令碼中的各種符號的意義

此符號後面的是註解文字,不會被執行,如果是在括號裡或者 後面,則變成一般符號 代表使用者的home目錄cd 分號,在同一行寫入多行指令 連續分號,case指令碼專用,代表一則命令終結 單引號,所見即所得,直接顯示單引號內容,防止萬用字元擴充套件和變數擴充套件 雙引號,執行變數解析後,再輸出 反引號,...

python中的各種符號

在這裡所作的是將所有的 python 符號和關鍵字列出來,這些都是值得掌握的重點。關鍵字 and del from not while as elif global or with assert else if pass yield break except import print class e...