课程: Learning Linux Shell Scripting
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
The elif clause
- [Instructor] There is still one more variation of the if we need to discuss. The elif which is an abbreviation of else if. It allows us to check a different expression than the one used in the if. Elif must come before the else which must be the last clause in the if statement. So, let's modify our script to use the elif. So, right here when we do the first echo, we'll do an elif and now we'll compare again the two numbers, USER_GUESS and this time we'll use a greater than and computer, then we need to put the then clause in and we'll echo you're too high. Then we need to change our else since it's a little bit different. This time we know that you're equal, so we'll just say you've guessed it. And we'll do a control S to save this, go to the terminal and run the script and we'll just say red and 60 and this gives us we're too high. If we say red and 40, we're gonna be too low and if we put it right on 50, you've guessed it and so, that's how we use the elif. Note the elif gets the…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。