16.2. What a script contains

This book is not about good scripting design techniques, but good reusable code. You do not have to make the script complicated when it can achieve the same results through solid understandable code. If I wrote a book that way, I might impress you, but it would take a lot longer for you to get to grips with the code. This is not my goal; my code works and it works using basic scripting techniques, which you will learn more quickly. You will then be able to impress your friends more quickly!

A script is not a compiled program: it is interpreted, line by line. The first line of the script should always start with


#!/bin/sh 

This lets the shell know where the Bourne shell interpreter is to be found on the system.

Any script can have comments; to put comments into your script, the first character of the line should be a hash (#), and the interpreter will ignore these lines. It is good practice to include the name of the script as the second line down as a comment.

A script is read from top to bottom. To be able to run a script, it must first be made executable. Make sure your path is set up properly, so your scripts can be run by supplying only the file name.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.172.243