WEBVTT NOTE This file was generated by Descript 00:00:00.072 --> 00:00:03.132 Drew K: Hey again, welcome back to coding with Drew in this video, 00:00:03.132 --> 00:00:04.362 we're going to learn about loops. 00:00:04.842 --> 00:00:08.622 Every language you're going to learn will have some form of loops, which will 00:00:08.622 --> 00:00:10.662 allow you to repeat sequences of code. 00:00:10.932 --> 00:00:12.432 While a condition is met. 00:00:13.232 --> 00:00:16.682 Each language handles them slightly differently, but it's a fundamental. 00:00:17.042 --> 00:00:20.972 Nailing this skill down will be exceptionally helpful in your future. 00:00:21.272 --> 00:00:22.892 Bash is no exception. 00:00:23.042 --> 00:00:26.132 And the way it handles loops is very simple comparatively. 00:00:26.672 --> 00:00:29.672 Especially when you look at like JavaScript or Java. 00:00:30.482 --> 00:00:37.462 In bash a while loop runs a set of commands while a set condition exists. 00:00:37.522 --> 00:00:39.472 And it exits with a zero. 00:00:40.222 --> 00:00:44.892 When a command gives a non-zero exit code every while loop starts with a 00:00:44.892 --> 00:00:50.592 reserve keyword while and ends with done the rest of the syntax is very 00:00:50.592 --> 00:00:54.542 similar to what we've already seen with an if statement, infinite loops. 00:00:54.572 --> 00:00:56.582 This is something you really need to know about. 00:00:56.612 --> 00:01:01.472 Infinite loops is a phrase that will you'll hear in every language they occur. 00:01:01.502 --> 00:01:06.722 When you create a while loop with no exit, meaning that it will run to infinity 00:01:06.722 --> 00:01:08.732 because it will always evaluate to true. 00:01:09.212 --> 00:01:12.092 While this may be desirable in certain edge cases, it's 00:01:12.092 --> 00:01:14.522 not so much for your computer. 00:01:14.522 --> 00:01:18.092 Your computer will likely crash and it should be avoided unless you 00:01:18.092 --> 00:01:20.672 know what you're doing, design your loops so that they'll eventually 00:01:20.672 --> 00:01:22.322 produce an exit code of one. 00:01:23.122 --> 00:01:26.562 Anyways, that's the introduction in the next video, we're going to see 00:01:26.562 --> 00:01:28.182 some examples and get our hands dirty. 00:01:28.362 --> 00:01:28.872 I'll see you there.