课程: Learning Linux Shell Scripting
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
The else clause
- [Instructor] Sometimes you'd like to do one thing if the expression is true and something else if it is false. That is where the else clause comes in. If the expression is false, then the commands following the else up to the fi are executed. And if it is true, it executes the commands in between the then and the else. So, let's go ahead and add the else to our script and we're gonna come in here and right after the echo, we'll say else and we're gonna echo out the color is NOT blue and here with our number comparison, we'll say else and we'll echo and there's actually two possibilities here. You're equal or too high. And we'll do a control S to save that. Go back down to the terminal. Let's go ahead and just clear the screen. And we will say if.sh and this time we'll type the color blue and we'll put in the number 45. So, we get the color is blue, you're too low, and this time we'll try blue again but we'll change the number to 55 which we know is too high and we get the color is…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。