Shell Script
Shell Script
Titles
• UNIX
• What is a command?
• Shell script
• Flavors of Unix Shells
• Shell Operations
• Examples
UNIX
Unix was developed by programmers and for
programmers.
Unix is designed so that users can extend the
functionality
To build new tools easily and efficiently
To customize the shell and user interface.
To string together a series of Unix commands to create new
functionality.
To create custom commands that do exactly what we want.
What is a command?
In UNIX, a command is a program that you can run.
In Mac OS or Windows, you point to the program
and click it.
To turn on command in UNIX, you type the name
and Enter.
Example:
$ date [Enter]
Shell
• A program that interprets commands
• Allows a user to execute commands by typing them
manually at a terminal, or automatically in programs
called shell scripts.
• A shell is not an operating system. It is a way to
interface with the operating system and run
commands.
Shell script
A shell script is a computer program
designed to be run by the Unix
shell, a command-line interpreter.
It acts as an interface between the
user and OS (kernel).
It’s known as “ command
interpreter”.
Flavors of Unix Shells
Two main flavors of Unix Shells
Bourne (or Standard Shell): sh, ksh, bash, zsh
• Fast
• $ for command prompt
C shell : csh, tcsh
• better for user customization and scripting
• %, > for command prompt
To check shell:
% echo $SHELL (shell is a pre-defined variable)
To switch shell:
% exec shellname (e.g., % exec bash)
Popular Shells
sh Bourne Shell
ksh Korn Shell
csh,tcsh C Shell (for this course)
bash Bourne-Again Shell
What is BASH?
• BASH = Bourne Again SHell