Download your favorite Linux distribution at LQ ISO.
Go Back > Blogs > hi2arun
User Name


Rate this Entry

Comment a block in shell

Posted 08-31-2011 at 12:22 AM by hi2arun
Tags bash, script

We all know, to comment out a line in shell script, '#' token is inserted in the line that needs to be made dead.

# This is a dead line
echo "This line is live"
However, '#' token can be pesky if a block of lines need to be commented out.
Say, to comment out the following block using '#'

# comment starts here
# All these lines
# are blocked
# using '#' token
# ...
# ...
# ...
# ...
# comment ends here
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...

All these lines
are blocked
using '#' token
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.
Posted in Uncategorized
Views 1097 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 09:54 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration