A useful way to comment out blocks of code in bash

Posted in: Bailey's Blog- Apr 08, 2013 2 Comments

Bash does not have an ‘easy’ way to comment out blocks of code – but this is simple enough.

At the beginning of the block you wish to comment out put:

: <<‘QWERTY’

and at the end of the block put:

QWERTY

I’ve used ‘QWERTY’ as it should be a string of characters which is not used in you code – adjust as needed.

2 Responses to “A useful way to comment out blocks of code in bash”

  1. kbailey
    Reply kbailey says:

    As a Brucie bonus…

    If you are editing using the shell-script(bash) mode in Emacs then Emacs will recognise the commented out block and colour it accordingly.

  2. Reply maicon says:

    thanks!

Leave a Reply