Basic Linux Tutorial
Computer Tutorial

Introduction to Shell Programming

Introduction to Shell Programming

Shell programs or shell scripts are files containing Linux commands, comments, and control structures. These are like batch processes where commands are interpreted and executed by the shell line-by-line. Any command that can be executed at the shell prompt can be included in a shell program. The shell provides very powerful features for writing shell programs. Many of the shell programs are used at startup and shutdown time.
Shell programs are also used by system administrators to automate routine jobs. Files containing the shell commands are executed at specified times using the Linux facility. Mostly shell programs help in controlling the size of log files, cleaning temporary files, and reporting errors to the system administrator through email.

Example of a simple shell script.

echo   "Our first script"
echo   "----------------"
echo   # This inserts an empty line in output.
echo   "We are currently in the following directory"
echo   "This directory contains the following files"

This program prints some messages on your terminal screen and then shows the current directory and lists files in this directory.