The Shadowless Sword Fragment 9 (Advanced Shell Script Programming)

Advanced Shell Script Programming

Conditional selection if statement
Select execution:
Note: if statement can be nested
Single branch


if judgment condition; then
condition is true branch code
fi
Double branch
if judgment condition; then
condition is true branch code
else
condition is false branch code
fi

Example: Please enter an age number, the system will prompt the corresponding prompt

[root@laobai ~#vim bitch.sh

test the results

[root @ laobai #bash bitch.sh
Please input your age:22
good good work
[root @ laobai #bash bitch.sh
Please input your age:33
good good work
[root @ laobai #bash bitch.sh
Please input your age:66
free your life
[root @ laobai #bash bitch.sh
Please input your age:666
are you people?

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325871937&siteId=291194637