Shell Scripting is an open-source computer program designed to be run by the Unix/Linux shell. Shell Scripting is a program to write a series of commands for the shell to execute. It can combine lengthy and repetitive sequences of commands into a single and simple script that can be stored and executed anytime which, reduces programming efforts.
The kernel is a computer program that is the core of a computer’s operating system, with complete control over everything in the system. It manages following resources of the Linux system.
A shell is special user program which provide an interface to user to use operating system services. A shell accepts human readable commands from user and convert them into something which kernel can understand. It is a command language interpreter that executes commands read from input devices such as keyboards or from files. The shell gets started when the user logs in or starts the terminal
Bourne shell (sh)
Korn shell (ksh)
Bourne Again shell (bash)
POSIX shell (sh)
The Bourne Shell: The prompt for this shell is $ and its derivatives are listed below:
POSIX shell also is known as sh
Korn Shell also know as sh
Bourne Again SHell also knew as bash (most popular)
The C shell: The prompt for this shell is %, and its subcategories are
Usually shells are interactive that mean, they accept command as input from users and execute them. However some time we want to execute a bunch of commands routinely, so we have type in all commands each time in terminal.
As shell can also take commands as input from file we can write these commands in a file and can execute them in shell to avoid this repetitive work. These files are called Shell Scripts or Shell Programs. Shell scripts are similar to the batch file in MS-DOS. Each shell script is saved with .sh file extension eg. myscript.sh
A shell script comprises following elements –
Shell Keywords – if, else, break etc.
Shell commands – cd, ls, echo, pwd, touch etc.
Control flow – if..then..else, case and shell loops etc.
There are many reasons to write shell scripts –
Become master in shell script click here
The command and syntax are exactly the same as those directly entered in command line, so programmer do not need to switch to entirely different syntax
Writing shell scripts are much quicker
Interactive debugging etc.
Prone to costly errors, a single mistake can change the command which might be harmful
Slow execution speed
Design flaws within the language syntax or implementation
Not well suited for large and complex task
Provide minimal data structure unlike other scripting languages.
To learn more about Linux click here