Hello, everyone.
Today is our first lesson in Besch scripting that script is a file that contains some best commands
in in order, and they are executed as if they had been typed from the terminal window itself by scripting
is very useful since we don't have to type the same commands over and over and we can just put them
in a file and executed when needed.
Best scripts can have an optional extension of that.
S.H. We don't have to add this extension, but it's a good to have it there to easily identify our script.
Let's have an example and create our first Hello World Best Script.
Our best script will begin with a harsh exclamation mark and then location of our best interpreter,
which is the bin bash, let's type that.
Although I'm using them as my text editor in this example, you can use your favorite text editor.
After we save our file, we need to give it executable permission, we can do that by typing the search
mod space plus X and then the name of our script,
the plus sign means we want to add permission and the X means execute so together and means add execute
permission to this file.
Since the script exists in our current directory, we can run it by adding that forward slash in front
of the file.
Nice, we have successfully created our first basket.
Now, if you remember our lesson about environmental variables, then let's talk about abash variables.
Variables are just names that we choose to store some data, especially if it's a long line that we
want to keep using over and over without retyping it.
Let's create a simple first and last name variables in our best script and then display them to the
screen.
Notice that we don't have any spaces before or after the equal sign.
Keep that in mind.
Otherwise, you will get a syntax error.
We can now echo our variables by adding dollar sign in front of it.
Let's execute our script.
Nice, keep in mind that if you add another word to our variable, it will be treated as a command,
which we don't want.
Let's try that.
It didn't like the word geek in our third line, and it treated as a command, so best practice when
using variables is to surround them with double or single quotes just to be safe.
A very useful thing we can do, investigating scripting is distorted, the result of some command to
a variable so we can use it again later in our script.
In order to do that, we need to put our command in parentheses and add dollar sign in front of it.
Let's try that.
Who am I command for our best script.
Another way to do this is to use the back to the back, the character is located to the left of the
number one in your keyboard.
Let's try it.
We have reached the end of this script and listen, thank you and see you in the next one.