I would like to use multiline comments under shell script. Under C / C++ I can use the following format
my c code
comment # 2
How do I put multi line comment under a shell script?
[donotprint][/donotprint]By default shell script can be commented out prefixing # character, for example:
# my comment goes here
For multiline-comment use the following syntax:
# my comment 1
# my comment 2
# my comment N
However, you can use HERE DOCUMENT feature as follows:
#!/bin/bash echo "Say Something" <<COMMENT1 your comment 1 comment 2 blah COMMENT1 echo "Do something else"
Another option as pointed out by Ikram in the comments section below:
#!/bin/bash foo=bar : ' This is a test comment Author foo bar Released under GNU ' echo "Init..." # rest of script
This is a test comment
Author foo bar
Released under GNU
' echo "Init..."
# rest of script
Please note that the : is shell builtin command. From the bash(1) man page:
No effect; the command does nothing beyond expanding arguments
and performing any specified redirections. A zero exit code is
So the syntax is:
: ' your comments here '
your comments here