Starting With Shell Script
What is a shell script?
A shell script is a command which would have been directly typed into a shell.
It can be a sequence of commands that you type regularly.By putting them into
a script we can reduce them to a single command.Also there is no difference in
syntax between interactive command line use and placing the commands in a
file.But there are some commands line history which we can only type in
interactive command line.
Why use shell scripts?
Shell scripts are used to combine lengthy and repetitive sequence of commands
into a single and simple command.We can create new commands using combinations
of utilities.It can also be used to generalize operations on a single set of data, into a
procedure that can be applied to any similar set of data.
Writing the script
First use one of the text editors like vi and write this inside it:
echo “Hello world”
and save the file using .sh extension,say hello.sh.
Making it executable
To do execute,tell linux that this is an executable file.
chmod +x hello.sh
Running the script
To run the script just go to the directory where the file is saved and type the following
The output will be: