Chapter 12. Programming the Korn Shell

Programming the Korn Shell

Introduction

When commands are executed from within a file, instead of from the command line, the file is called a shell script and the shell is running noninteractively. Writing Korn shell scripts requires a few steps, as outlined in the following section.

The Steps in Creating a Shell Script

A shell script is normally written in an editor and consists of commands interspersed with comments. Comments are preceded by a pound sign (#).

The First Line

At the top left corner, the line preceded by #! (often called shbang) indicates the program that will be executing the lines in the script. In Korn shell scripts, this ...

Get UNIX® Shells by Example Fourth Edition 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.