使用參數傳遞內容: $0,$#,$1,$2,$n,$$(PID)
使用交互:read 讀入數據給變量, echo 輸出數據, printf 輸出數據
read -p 'please input your name: ' TEST
printf “$TEST” # 避免空格
執行shell: pstree
1、執行權限,絕對路徑(相對路徑);# 子shell
2、bash 絕對路徑(相對路徑); # 子shell
3、. 絕對路徑(相對路徑); # 當前shell, 變量
bash腳本中的流程控制-----------------------
條件判斷控制: [ * ], &&, || , if, case ;-z爲空; -n非空;
循環控制:while, utile, for, break, continue
bash -vx 腳本 # 執行可見,調試
------------------------------------------
bash的變量分爲:
環境變量:環境變量是可以被子shell引用的變量;
普通變量:普通變量只在當前shell中有效;
set顯示環境變量和普通變量;env只顯示環境變量;
export可以把普通變量變成環境變量;unset可以刪除一個變量;
bash運算符
[ test ],&&,||,'',"",$[]算術運算,\,$()子shell,
touch {a,b}-{1,2,enum}
------------------------------
bash;exit;man bash;
/etc/profile;# -
/etc/profile.d/*.sh;
~/.bash_profile;
~/.bashrc;
/etc/bashrc;
~/.bash_logout;