Q. I’d like to use multiline comments under shell script. Under C / C++ I can use format
/*
my c code
comment # 2
blah
*/
How do I put multi line comment under a shell script?
A. By default shell script can be commented out prefixing # character for example:
# my comment
For multilinecomment use
# 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"Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- My 10 UNIX Command Line Mistakes
- Linux: 20 Iptables Examples For New SysAdmins

- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Facebook it - Tweet it - Print it -


{ 2 comments… read them below or add one }
you can also put multi-line comments using
:’
comment1comment1
comment2comment2
comment3comment3
comment4comment4
‘
Err, no.
You can’t, at least in bash 4.0.33, which I’m using.
Aha, yes you can, but what is not clear (not your fault, Ikram – just the way the web page displays), is that you need a space between the : and the opening ‘
so:
#!/bin/bash
echo “Hello”
: ‘
comment
comment
‘
echo “Bye”
Works, which is new for me, so thanks!