This post is about how to write a comment in bash shell tutorials with examples.
‘Comments’ are code statements that the shell skips while it is running.
Every programming language has a
comments feature that contains a description of the line of code or statements.
Comments inline of the code help developers to edit code and understand it better.
The bash scripting language allows you to write the following comment types.
- Single comments
- Multi line comments
Single line Comment in bash and shell
These comments contain a single line always prefixed with the
These comments contain strings about the shell script line of code.
Single-line comments should always be placed on a separate line.
. You can include a comment in a separate line or inline.Single Line Comments always starts with the
# Single line comments
Blank space after the # symbol is not required. Following is a Single Line Comment example in a shell script.
# Single line comments. AGE=45 echo "Age:$AGE"
Multi-Line comments in a shell script
Multi-Line comments are placed in more than one-line comments.
It is one way of writing multiple-line comments using single-line comments with each line as a single-line comment symbol.
# Line1 comments # Line1 comments # Line1 comments
Multiple line comments enclosed in (:') and (') It contains
- Comments start with a colon(:) followed by '
- followed by multiple lines of comments
- Comments end with ' Here is a Syntax
: ' multiline comments example1 multiline comments example2 multiline comments example3 '
Here is a Multi-Line Comment example
: ' multiline comments example1 multiline comments example2 multiline comments example3 ' echo "testing multi-line comments"
To Sum up, Learned how to add single and multi-line comments in shell script programming