Creating Shell Scripts: the Basics

Creating a shell script is a matter of writing a text file containing valid commands and saving the text file. The script can then be run as an argument to the shell command or as a standalone executable file. Generally, you'll want to make scripts executable on their own.

To create a shell script:

1.
Open a text editor, such as Gnotepad+ (Figure 12.10).
2.
For the script's first line, type the following:
#! /bin/bash
This is the complete path to the shell that should run the script.
3.
For the script's next line, on general principles, type a pound sign (indicating a comment line) followed by a description of the script:
# A baby script
4.
Type the line that does the business of the script (it echoes text to ...

Get Red Hat Linux 6: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.