Introduction of Shell Scripting
SHELL SCRIPTING
INTRODUCTION OF SHELL
WHAT IS SHELL? A shell is a special program which acts as an interpreter between the user and the operating system. Shell accept human readable commands from a user and convert them into Kernel readable language. It is a command language interpreter that execute commands read from input devices such as keyboards or from files. The shell gets started when the user logs in or start the terminal.
Types Of Shell
There are Several types of shell are available. Some are
1.) Bourne shell The Bourne shell, called "sh," is one of the original shells, developed for Unix computers. some of the categories of bourne shells are listed below • Korn shell (ksh) • Bourne Again shell (bash) It is the default shell on many Linux distributions • POSIX shell (sh)
2.) C shell
It was developed for a developer who has written C and C++ in Linux operating system.
some of the categories of C shells are listed below • C shell (csh) • TENEX/TOPS C shell (tcsh)
WHAT IS SHELL SCRIPT?
Shell Script is a file which contains a series of Linux commands, Those commands are executed by the shell. It can combine lengthy and repetitive sequences of commands into a single and simple script, which can be stored and executed anytime. This reduces the efforts of the common user.
SHELL COMMANDS
ls, cd, cat, mkdir, cp, mv, for, while doing, etc…
SHABANG
#!/bin/bash
It is the first line should be present in every shell scripts. It’s called a shebang.
It represents the type of shell which we use to execute the script.
Example
List OF BASH SCRIPTS
[root@linuxhelp11 Desktop]# ll
total 12
-rwxr-xr-x 1 root root 24 Jul 1 19:31 bash.sh
-rwxr-xr-x 1 root root 22 Jul 1 19:51 csh.sh
-rwxr-xr-x 1 root root 22 Jul 1 19:33 zsh.sh
Content in each script
[root@linuxhelp11 Desktop]# cat bash.sh
#!/bin/bash
sleep 120
[root@linuxhelp11 Desktop]# cat csh.sh
#!/bin/csh
sleep 120
[root@linuxhelp11 Desktop]# cat zsh.sh
#!/bin/zsh
sleep 120
Execute script and check for SHELL using ps command
[root@linuxhelp11 Desktop]# ./bash.sh &
[7] 6158
[root@linuxhelp11 Desktop]# ps -fp 6158
UID PID PPID C STIME TTY TIME CMD
root 6158 5729 0 19:58 pts/1 00:00:00 /bin/bash ./bash.sh
[6] Done ./bash.sh
[root@linuxhelp11 Desktop]#
[root@linuxhelp11 Desktop]# ./csh.sh &
[8] 6169
[root@linuxhelp11 Desktop]#
[root@linuxhelp11 Desktop]# ps -fp 6169
UID PID PPID C STIME TTY TIME CMD
root 6169 5729 0 19:58 pts/1 00:00:00 /bin/csh ./csh.sh
With this, the Introduction to Shell comes to an end.
Comments ( 0 )
No comments available