A useful way to comment out blocks of code in bash

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.

Share Post :

2 Comments

  • kbailey
    9th April 2013 at 10:30 am 

    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.

  • maicon
    5th January 2015 at 5:34 pm 

    thanks!

Leave a Reply