Bash Scripting

BASH Scripting
What is a shell script?
Script: a writing; a written document –
Webster's Dictionary
A shell script is an easy-to-use tool for
application building that “glues together”
system calls, tools, utilities, etc.
Shell Scripts can invoke the commands
available in Linux.
Useful tool for System Administrators
Avoid having to retype repetitive commands
Scripts become a program – a tool that can
easily be customized for a particular
How? #!/bin/bash
Start with a sha-bang (#!)
Placed at the head of a script
#! is a two-byte magic number
designating the file type (or
executable shell script)
Tells your system that this file is a set
of commands to be fed to the
command interpreter indicated
Chmod then execute
• Change mode: command lets a user tell the
system how much access it should permit a
• Make the BASH script executable
chmod +x
• Execute your script (dot-slash)
We shall now make a simple BASH script!