LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > hi2arun
User Name
Password

Notices


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.
Eg:

Code:
# 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 '#'

Code:
# 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...

Code:
<<COMMENT
All these lines
are blocked
using '#' token
...
...
...
...
COMMENT
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 1340 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 03:14 AM.

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