How to write comments in Bash
In this tutorial, we are going to learn about how to write the comments in Bash with the help of examples.
Comments helps us to understand the code better, in case if we forgot what is happening on the particular line of code.
Comments are ignored by the interpreter.
There are two ways to write comments in Bash.
Single line comment
To we can write a single line comment in Bash, we can use the forward slashes #
followed by the comment.
Here is an example:
# this is a single-line comment in bash
Anything we written after #
is ignored by the compiler.
Multiline comments
To write a multiline comments, we can use the : '
and '
syntax in Bash.
Here is an example:
: '
you can
see mee
in multiple lines
'
In the above example, the multiline comment starts after the : '
and ends at '
.
Or you can write a muliline comment like this:
<<COMMENT
This is a multiple line
comment
in Bash
COMMENT