Distributed Networks Distributed Networks

Unix Shell Scripts   «Prev  Next»
Lesson 1
Writing your first script
So far in this course you have learned a lot about shells and shell scripts, but you have not actually created one.
You have learned what types of shells are available, how shell scripts can be used compared to other scripting languages, and what components make up a shell script.
This module will discuss creating and executing your first shell script.
By the end of this module you will be able to:
  1. Define what makes a text file a shell script
  2. Write information to the screen using a script command
  3. Read keyboard input using a script command
  4. Add explanatory comments in your script
  5. Set the UNIX file permissions to allow your script file to be executed
  6. Run a script file from a command line
Shell scripts are short programs that are written in a shell programming language and interpreted by a shell process. They are extremely useful for automating tasks on Linux and other Unix-like operating systems.
A shell is a program that provides the traditional, text-only user interface for Unix-like operating systems. Its primary function is to read commands that are typed into a console, which uses a text display mode, (also known as a terminal window). The default shell on Linux is the very commonly used and highly versatile bash.
A feature of bash and other shells used on Unix-like operating systems is that each contains a built-in programming language, referred to as a shell programming language or shell scripting language, which is used to create shell scripts.
Among the advantages of using shell scripts are that they can be very easy to create and that a large number are already available in books and on the Internet for use with or without modification for a wide variety of tasks. Shell scripts are also employed extensively in the default installations of Unix-like operating systems.