Comments

Using a # at the start of a line (without the ! of a shebang) turns the line into a comment.

 

Comment Frequently!!!

 

#    This is a comment, to remind me of what follows!

 

 

Alternatively, the HEREDOC /  HERE DOCUMENT notation <<IDENTIFIER can be used to create comments over multiple lines and is terminated by stating the same IDENTIFIER without the <<

 

#! /bin/bash

# The shell will ignore this comment

echo "Example of a block of comment lines:"
<<COMMENT
	A bunch of text
	can now be created
	over multiple lines
COMMENT
echo "Notice how the commented heredoc section is ignored."

 

Invoke:

sh comments.sh

 

Output:

Example of a block of comment lines:
Notice how the commented heredoc section is ignored.