The Linux Shell Scripting
The Linux Shell Scripting
What Is a Shell?
● A shell is a program that takes commands typed by the
user and calls the operating system to run those
commands.
● C Shell
● Korn Shell
● Bash Shell
● Tcsh Shell
Changing Your Default Shell
● Tip: To find all available shells in your system type following
command:
$ cat /etc/shells
Linux Kernel
• Shell script can take input from user, file and output them
on screen.
● Make sure you use .bash or .sh file extension for each script.
This ensures easy identification of shell script.
Setup executable permission
● Once script is created, you need to setup executable
permission on a script. Why?
● Examples
◦ $ bash bar
◦ $ sh bar
◦ $ ./bar
Variables in Shell
● Examples:
◦ $vehi=Bus
◦ $ n=10
◦ $ echo $vehi
◦ $ echo $n
Cont…
● Don’t try
◦ $ echo vechi
◦ it will print vehi instead its value 'Bus‘.
◦ $ echo n
◦ it will print n instead its value '10‘.