Chapter 7: Introduction to Shell Scripts

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 Section 1.17 for a refresher on permissions).