使用参数传递内容: $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;