一 test 测试:
测试命令 test [ ] [[ ]] (( ))
打开man test 逐一介绍每个参数
浮点计算:echo 'scale=2;1/3'|bc -l
测试操作
命令执行后会返回到一个系统变量中 $?
如果$?值为0 表示命令执行成功 否则为失败
二流程控制: if while for
#!/bin/bash read -p 'please input username:' usr read -p 'please input passwd:' passwd if [ $usr = 'alex' -a $passwd = 'alex3714' ];then echo 'login successful' else echo 'username or password is worng' fi