一 test 测试:

测试命令 test [ ] [[ ]] (( ))
打开man test 逐一介绍每个参数

Shell 语句

 

浮点计算: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
用户测试

相关文章:

  • 2021-11-13
  • 2021-12-19
  • 2021-10-01
  • 2021-05-25
  • 2021-11-07
  • 2022-12-23
  • 2021-04-28
猜你喜欢
  • 2021-05-29
  • 2021-06-24
  • 2022-12-23
  • 2021-12-12
  • 2021-11-24
  • 2022-01-26
相关资源
相似解决方案