Shell Script Put Multiple Line Comments under Bash/KSH

/*

my c code

comment # 2

blah

foo bar

....

*/

Tutorial details Difficulty Easy (rss) Root privileges No Requirements None Time 1m

# my comment goes here

ADVERTISEMENTS



Bash Shell Script Put Multiple Line Comment Syntax

I would like to use multiline comments under shell script. Under C / C++ I can use the following format:How do I put multi line comment under a shell script? Can you tell method to set multiline shell script comments?By default shell script can be commented out prefixing # character, for example:

For multiline comment use the following syntax:

#!/usr/bin/env bash # my comment 1 # my comment 2 # my comment N #!/usr/bin/env bash # 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" #!/bin/bash echo "Say Something" <<COMMENT1 your comment 1 comment 2 blah COMMENT1 echo "Do something else"

This type of redirection tells the shell to read input from the current source (HERE) until a line containg only word (HERE) is seen. HERE word is not subjected to variable name, parameter expansion, arithmetic expansion, pathname expansion, or command substitution. All of the lines read up to that point are then used as the standard input for a command. Files are processed in this manner are commonly called here documents. If you do not want variable name, parameter expansion, arithmetic expansion, pathname expansion, or command substitution quote HERE (COMMENTS) in a single quote: