Comment a block in shell
Posted 08-31-2011 at 12:22 AM by hi2arun
We all know, to comment out a line in shell script, '#' token is inserted in the line that needs to be made dead.
Eg:
However, '#' token can be pesky if a block of lines need to be commented out.
Say, to comment out the following block using '#'
Well.. this could be annoying if by mistake, some '#' tokens are deleted... mm .. interpreter errors while running.. ah!
Using 'block comment' option is a lot simpler and handy that gives the freedom to add/comment out any number of lines... it is simple to do.
Here you go...
As shown, start of comment is marked by "<<" and a label. In the given example, it is "<<COMMENT" and the same label is used to mark end of comment.
Eg:
Code:
# This is a dead line echo "This line is live"
Say, to comment out the following block using '#'
Code:
# comment starts here # All these lines # are blocked # using '#' token # ... # ... # ... # ... # comment ends here
Using 'block comment' option is a lot simpler and handy that gives the freedom to add/comment out any number of lines... it is simple to do.
Here you go...
Code:
<<COMMENT All these lines are blocked using '#' token ... ... ... ... COMMENT
Total Comments 0