One of the basic things as we should know is how to run a shell script.
So when you created there are different ways you could run it you could run it through absolute path
or there's another one that's called relative path so absolute path is if let's suppose if you are standing
right at the first step of stairs and you have to pick up something on the very last year and the top
you have to actually either shoot from the first year all the way to the last year on top and grab that
thing that you're trying to grab or there's another one.
Another way is relative path the relative path is that you actually walk up to the stair and then grab
that thing that you want it to grab the same way absolute path and relative path works.
If you do not know what exactly absolute path and relative paths are I would recommend you that you
should you know try to look it up online and see what they are and how they work and you'll find tons
of articles there and make sure you type absolute path and Linux or absolute path and relative papped
in Linux as well.
So the way it works is I have my Linux machine up let me log into my Linux machine.
So I have my script right here it's called X Y Z dash script.
If you'd notice I am in my slash home slash I solved and slash script directory I created a directory
called scripts in my home directory and I create all my scripts in that directory.
So if I am already in that directory I could run the script or if I'm not in my directory Let's see
if I just do a CD and which directory I'm in I'm in slash root.
So the script that I want to run it's just a test script that I created earlier.
That's if you type script name x y z dash script and then you hit enter.
You'll see it says bash the script name command not found.
Why.
Because the Linux operating system is trying to find that script in slash root directory and I do not
have that script and slash root directory.
So I would have to specify the absolute path to run the script and the absolute path would be just the
same way as if you are standing at the bottom of the stairs and then you have to fetch something from
the top of the stairs then you actually through some kind of means or like a stick or something then
you could grab it.
So the same way you can specify the entire path just slash home my user directory scripts and now the
name of the script.
Now when I run the script I'll hit enter and you will see is just a script that is actually Ecko out
or print hello world on the screen.
How does this create it.
I will cover that in later lectures but just to focus.
This is how you need to run a script using absolute path.
Now what if you are in a relative path which is that you are already in a home.
I saw and scripts directory see used CD into that directory you do PWT and you'll see the path is the
complete path.
Now now the script name is again and you do ls mysel TR tiara have the script X Y Z script.
Now when you run this group now
and hit enter it still cannot find it.
Why.
Because when you are inside of a directory you will always have to specify that you want to run the
script.
But then this same directory and that is the relative path.
And to do that you have to specify dot slash and then the name of the script you can hit tab the autocomplete.
So now you hit enter and you'll see it ran.
So keep that in mind.
There are two ways you can run the script one through absolute path and one through the relative path.
If you are let's say in slash home directory and now you want to run the script you can still specify
the entire pass lying home starting my user directory or you could just simply start from the directory
you are in.
So you are in I of from this home on word IVs all scripts and the script name.
And you see it works here too because you do you have to let the operating system know where your script
exactly is located.
So that's a basic a bad scripting how you run it.
So please remember these are two main points about running the script.