Shell scripting, let's get into some fun.
Yes, everyone, let's this time to get into some fun, we're going to create our own scripts, our
own commands to run and automate tasks.
So what is a shell script?
So basically a Shell script is an executable file containing multiple shell commands that are executed
sequentially.
So every time you create a shell and you create, you have a first command followed by second, third
and fourth.
Always the first command will be executed, followed by the second and third and so on.
So the file of a shell contains the first thing.
The first line is the shell itself.
Always define the shell with pound bang slash bin slash bash in Linux.
Most of the time the exclamation point is referred to as bang.
So the first line of a shell script is always start with the shell.
It's going to run in.
Most of the scripts that we will cover are all going to be Basche scripting then the inside of a Shell
script.
We also have comments where we could tell what this command or what this script does.
Every time we put comments, we always start with hash pound sign, followed by all the commas that
we want to add.
Then we have commands, of course, what exactly you want the script to do.
And then we also have the statements which will tell the script if then while or do a for loop or all
those different conditions level, we will cover one by one and those are different.
Shell scripting a shell script should have executable permission, but it means that when you create
a script, of course a script is just an empty file.
Everything in Linux is just file a flat file until you change it to an executable or link or just a
flat file.
So if you go back to the executable permissions learning that you had, you'll remember that the third
bit in in a file is always executable, which is X and on the group is X and on the others as X..
So in order for a script to run, it has to has this X bet on it.
A Shell script has to be called from the absolute path it always has.
You always have to define the complete path of the shell, meaning in this case, like home your user
directly and the name of the script.
If it is not in an absolute path, you could still run it.
If you are in the current location, then you all have to do is put a dot slash and the name of your
script.