1 00:00:00,540 --> 00:00:01,410 Hello, everyone. 2 00:00:02,100 --> 00:00:09,300 Today is our first lesson in Besch scripting that script is a file that contains some best commands 3 00:00:09,300 --> 00:00:17,340 in in order, and they are executed as if they had been typed from the terminal window itself by scripting 4 00:00:17,340 --> 00:00:22,380 is very useful since we don't have to type the same commands over and over and we can just put them 5 00:00:22,380 --> 00:00:24,350 in a file and executed when needed. 6 00:00:25,980 --> 00:00:29,370 Best scripts can have an optional extension of that. 7 00:00:29,370 --> 00:00:36,420 S.H. We don't have to add this extension, but it's a good to have it there to easily identify our script. 8 00:00:38,400 --> 00:00:42,270 Let's have an example and create our first Hello World Best Script. 9 00:00:50,600 --> 00:00:57,170 Our best script will begin with a harsh exclamation mark and then location of our best interpreter, 10 00:00:57,170 --> 00:01:00,350 which is the bin bash, let's type that. 11 00:01:09,490 --> 00:01:15,220 Although I'm using them as my text editor in this example, you can use your favorite text editor. 12 00:01:26,210 --> 00:01:32,310 After we save our file, we need to give it executable permission, we can do that by typing the search 13 00:01:32,360 --> 00:01:36,920 mod space plus X and then the name of our script, 14 00:01:46,340 --> 00:01:54,050 the plus sign means we want to add permission and the X means execute so together and means add execute 15 00:01:54,050 --> 00:01:55,510 permission to this file. 16 00:01:57,260 --> 00:02:03,620 Since the script exists in our current directory, we can run it by adding that forward slash in front 17 00:02:03,620 --> 00:02:04,250 of the file. 18 00:02:10,530 --> 00:02:14,320 Nice, we have successfully created our first basket. 19 00:02:16,020 --> 00:02:21,930 Now, if you remember our lesson about environmental variables, then let's talk about abash variables. 20 00:02:23,820 --> 00:02:29,670 Variables are just names that we choose to store some data, especially if it's a long line that we 21 00:02:29,670 --> 00:02:33,200 want to keep using over and over without retyping it. 22 00:02:34,800 --> 00:02:40,170 Let's create a simple first and last name variables in our best script and then display them to the 23 00:02:40,170 --> 00:02:40,620 screen. 24 00:02:55,150 --> 00:02:59,210 Notice that we don't have any spaces before or after the equal sign. 25 00:02:59,800 --> 00:03:00,740 Keep that in mind. 26 00:03:00,790 --> 00:03:02,740 Otherwise, you will get a syntax error. 27 00:03:04,160 --> 00:03:08,110 We can now echo our variables by adding dollar sign in front of it. 28 00:03:21,460 --> 00:03:22,930 Let's execute our script. 29 00:03:29,960 --> 00:03:35,990 Nice, keep in mind that if you add another word to our variable, it will be treated as a command, 30 00:03:35,990 --> 00:03:36,990 which we don't want. 31 00:03:38,150 --> 00:03:38,990 Let's try that. 32 00:03:54,010 --> 00:04:01,480 It didn't like the word geek in our third line, and it treated as a command, so best practice when 33 00:04:01,480 --> 00:04:05,860 using variables is to surround them with double or single quotes just to be safe. 34 00:04:25,450 --> 00:04:30,400 A very useful thing we can do, investigating scripting is distorted, the result of some command to 35 00:04:30,400 --> 00:04:33,190 a variable so we can use it again later in our script. 36 00:04:34,600 --> 00:04:40,870 In order to do that, we need to put our command in parentheses and add dollar sign in front of it. 37 00:04:42,460 --> 00:04:43,160 Let's try that. 38 00:04:43,180 --> 00:04:45,550 Who am I command for our best script. 39 00:05:10,300 --> 00:05:15,910 Another way to do this is to use the back to the back, the character is located to the left of the 40 00:05:15,910 --> 00:05:17,860 number one in your keyboard. 41 00:05:18,580 --> 00:05:19,510 Let's try it. 42 00:05:35,320 --> 00:05:39,540 We have reached the end of this script and listen, thank you and see you in the next one.