Unix Shell Scripts   «Prev 

Comments in a Shell Script

1) The first line of the script names the command interpreter.
#!/bin/sh
#=================================
# This sample script contains only 
# a few commands 
# ================================
# Request username and record for later use 
echo Please enter your name:
read MYNAME
# Confirm that the name is correct before proceeding 
echo Is $MYNAME the correct name?
read ANSWER
if[ANSWER ="Y"]
then
The first line of the script names the command interpreter.

2) Blank lines are skipped
Blank lines are skipped.

3) All comment lines are skipped; the first line to be executed is the line with the echo command.
All comment lines are skipped; the first line to be executed is the line with the echo command.

4) The next line executed is the line containing the read command.
The next line executed is the line containing the read command.

5) Blank lines and comments are skipped; the next echo command is then executed.
Blank lines and comments are skipped; the next echo command is then executed.

6) The next read command is executed, and the script proceeds with other commands, skipping all comment lines.
#!/bin/sh
#=================================
# This sample script contains only 
# a few commands 
# ================================
# Request username and record for later use 
echo Please enter your name:
read MYNAME
The next read command is executed, and the script proceeds with other commands, skipping all comment lines.