hello guys welcome to the next video on Linux command line tutorial for beginners in this video we will see how we can create our script in Linux and we will also see how we can execute our script and we will learn how we can write for example our first hello world script now scripting in general is really you know deep concept and I can make a separate tutorial about scripting itself right so in this video I just want to give you the brief introduction about scripting and how you can use scripting so that you can build on that knowledge and you can you know learn ago about scripting in different video or different you know so from this different source right so first of all what is a script a script is a text file that contains a sequence of command for our Linux based operating system so let's see how we can create a script so I'm going to open our terminal first of all and in this terminal first of all let's say we want to create a script on the desktop so I will just change the directory to the desktop and then I will use our Nano editor or creating a script so for creating a script you just need to write Nano and then the script name so for example I will name my script as my script itself now it's enough to give this name my script here but it's a good practice to give an extension of SH here for you know just showing the user that it's a script okay so I'm just adding the extension here but if you don't add this extension here it will work fine so it's so not going to be different if you don't add this extension now first of all we need to know where our Bash is located on our system so what I'm going to do is before creating a file or let's just create a file and then we are going to see for them so nano and then the name of the script and placenta and it's going to open this kind of editor to you right now first line which you write in a script is this line which you need to use or it's a good practice to use this so first is you need to write hash and then this exclamation mark which is called hash Bank and then the location of your bash now what I'm going to do is I'm going to open a different terminal and then we will see the location of our bash where is our bash right now what we are going to do is just to which and then just write bash here okay and then press ENTER and it gives this answer so this which command we are going to learn later what is this which command and what it does is but just open a new terminal and just write which bash and it's going to give you the location where bash is located so this is the location so just take this location and after this hash Bank which we have written here you need to write this location so /bin for slash bash okay which is this location here okay so we just needed to know the location and whatever the location is you just need to write here after this hash bang okay and now you can close the other terminal so this tells the you know interpreter that this is a script which is using bash and then as I have told you the script is a sequence of commands so for example I can normally write LS for listing for example let's do long listing with this script first of all right so just hash bang and then the long listing which is which you write on the terminal it will list out the of you know files or directory on your terminals right now in order to save it you just need to write ctrl o + + Enter which will save it and then ctrl X to exit so you can see here our script is created now in order to execute the script first of all let's see when we execute it what happens so normally you need to give the permission execute permission to your script but if you do it without giving the permission let's see what happens so to execute a script you just need to write dot forward slash and then the name of your script something like this so my script right so just write my script here dot SH ok and then when you execute it it says permission denied because your script doesn't have the execute permission when you create it ok so in order to give the execute permission you need to just give the execute permission to it so you can just write chmod plus X for giving the execute permission to use a group and the others and then your script name for example ok and then press enter and now your script has the execute permission right so in the last 3 video we have been learning how to give the permission to the script and that's why I'm I was you know creating those video to you know let you know how you can change the permission of a file now this will change the permission of a file to the execution so you can execute this script by giving this permission now once again when we do dot the forward slash and then the script name and press Enter what it does is it's going to list out the long listing of your desktop right so you can see let me just make it a little bit bigger and once again execute it again and you can see it has done the long listing off on the desktop so you can we have three files on the desktop and each have their own permission so first as the directory other is the file dot txt and third one is the my script dot SH which have all the execute permission here okay so this is a simple for example hello world script you can write us let's modify our script and let's see what else we can do so single command we can know uhm you know you can ask why we need script for executing a single command so let's go to the script again so I will just write Nano and then my script and this is a very basic example I have given you but with this scripting you can execute all you know sequence of common not only one command but for example let's do for example I will do LS and then I'll echo something and let's echo hello world here ok and then I will just save it ctrl o and press ENTER and then control X and once again when I execute this script it first of all list out the contents of the directory and then it prints the hello world which is using the echo command right now I have shown you in the echo command tutorial that we can also create a variable in you know you for using it in the echo so for example I will create a variable let's say it's called string is equal to and I will assign something to it let's say hello world itself something like this ok and with echo you can just call this variable by using this dollar symbol so just write something like this ok so swing and using the the dollar symbol before the variable name you can echo it okay so I will just save it and the presenter executes I will exit it and then once again execute the command and it's doing the same so you can see here in this script we are performing the you know cease of command and this is what scripting is so you can write you know sequence of you know command here and execute it and scripting is much advanced than this so it has a functions and it has loops and if conditions so you know it's a different topic to learn scripting but I have wanted to know let you know that this kind of scripting exists so you can build on this knowledge and learn about scripting there is it so really you know important if you want to pursue your career in Linux for example right so I hope you have enjoyed this video please rate comment subscribe and bye for now
Video Description: Linux Command Line Tutorial For Beginners 20 - Introduction to Bash Scripting for Software Development 2023 is part of Complete Linux Course: Become a Linux Professional preparation.
The notes and questions for Linux Command Line Tutorial For Beginners 20 - Introduction to Bash Scripting have been prepared according to the Software Development exam syllabus.
Information about Linux Command Line Tutorial For Beginners 20 - Introduction to Bash Scripting covers all important topics for Software Development 2023 Exam.
Find important definitions, questions, notes, meanings, examples, exercises and tests below for Linux Command Line Tutorial For Beginners 20 - Introduction to Bash Scripting.
Video Lecture & Questions for Linux Command Line Tutorial For Beginners 20 - Introduction to Bash Scripting Video Lecture | Complete Linux Course: Become a Linux Professional - Software Development - Software Development full syllabus preparation | Free video for Software Development exam to prepare for Complete Linux Course: Become a Linux Professional.
Information about Linux Command Line Tutorial For Beginners 20 - Introduction to Bash Scripting
Here you can find the meaning of Linux Command Line Tutorial For Beginners 20 - Introduction to Bash Scripting defined & explained in the simplest way possible.
Besides explaining types of Linux Command Line Tutorial For Beginners 20 - Introduction to Bash Scripting theory, EduRev gives you an ample number of questions to practice Linux Command Line Tutorial For Beginners 20 - Introduction to Bash Scripting tests,
examples and also practice Software Development tests.