Bash Shell scripts
Cecilia M. Curlango Rosas
1
Main Topics
• What are shells?
• What are scripts?
• What are scripts used for?
2
Image: http://flylib.com/books/en/2.872.1.85/1/
3
What is a shell?
• A shell is a program that reads the command line
and executes the commands the user writes.
• A shell also lets you do tasks like control programs,
redirect input and output and provides a language
for writing scripts.
• On a Linux system, the user can select what shell
he wants for his system.
4
Why learn to use the shell?
http://linuxcommand.org/learning_the_shell.php
5
What shells are there?
• The Bourne shell was one of
the most important shells used
in the first Unix versions.
• Stephen R. Bourne from Bell
Labs wrote it.
6
What shells are there?
• All Unix type systems have at least one shell that is
compatible with the Bourne shell.
• The name of the program for this shell is sh.
• Its default prompt is $.
7
What shells are there?
• The C shell was developed by
Bill Joy for Berkeley Software
Distribution (BSD).
• Its syntax is similar to the C
programming language.
• It is used mostly for interacting
with the terminal, not for
writing scripts.
8
What shells are there?
Derived from Bourne Shell Derived from C shell Others
Almquist shell (ash) TENEX C shell (tcsh) wish (Tcl/Tk)
Bourne-Again shell (bash) Hamilton C shell scsh (Scheme)
Debian Almquist shell (dash)
Korn shell (ksh)
Public domain Korn shell (pdksh)
MirBSD Korn shell (mksh)
Z shell (zsh)
9
Shells
Image from: http://www.ibm.com/developerworks/library/l-linux-shells/
10
Shell Configuration Files
11
http://en.wikipedia.org/wiki/Unix_shell
Shell Architecture
Image from: http://www.ibm.com/developerworks/library/l-linux-shells/
Cecilia Curlango Rosas
12
What is a script?
• A script is a file that has executable commands
that make up a program.
• In this course, all these terms will mean the same
thing: Bash shell script, Bash script, shell script
and script.
• A Bash shell script is a program written in the Bash
programming language.
13
What are scripts used for?
• Administrative system tasks like: disk backups and
checking log files.
• Interactive tasks
• Install and configure programs
14
References
• Bash programming HOW-TO http://tldp.org/
HOWTO/Bash-Prog-Intro-HOWTO.html
• Wiki book Bash scripting http://en.wikibooks.org/
wiki/Bash_Shell_Scripting
15