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 http://a%20rel='nofollow'%20class='comment-reply-link'%20href='#comment-2389'%20onclick='return%20addComment.moveForm(%20comment-2389,%202389,%20respond,%202298%20)'%20aria-label='Reply%20to%20kbailey'%20-%20Reply/a

    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 http://a%20rel='nofollow'%20class='comment-reply-link'%20href='#comment-2390'%20onclick='return%20addComment.moveForm(%20comment-2390,%202390,%20respond,%202298%20)'%20aria-label='Reply%20to%20maicon'%20-%20Reply/a

    thanks!

Leave a Reply