Creating a Script File
To place shell commands in a text file, first you need to use a text editor (see Chapter 10) to create a file and then enter the commands into the file.
When creating a shell script file, you must specify the shell you are using in the first line of the file. Here's the format for this:
#!/bin/bash
In a normal shell script line, the pound sign (#) is used as a comment line. A comment line in a shell script isn't processed by the shell. However, the first line of a shell script file is a special case, and the pound sign followed by the exclamation point tells the shell what shell to run the script under (yes, you can be using a bash shell and run your script using another shell).
After indicating the shell, commands are entered onto each line of the file, followed by a carriage return. As mentioned, comments can be added by using the pound sign. An example looks like this:
#!/bin/bash
# This script displays the date and who's logged on
date
who
And...