Chapter 7. INTRODUCTION TO SHELL SCRIPTS

If you can enter commands into the shell, you can write Bourne shell scripts. A script is a series of commands written in a file, and the shell reads the commands from the file just as it would if you typed them into a terminal.

As with any program on Unix systems, you need to set the executable bit for the script file, but you must also set the read bit. The easiest way to do this is as follows:

chmod +x script

This chmod command allows other users to read and execute script. If you don't want that, use the absolute mode 700 instead (and refer back to File Modes and Permissions for a refresher on permissions).

Shell Script Basics

All Bourne shell scripts should start with the following line, indicating that ...

Get How Linux Works 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.