Comment out block of code in bash shell script

Credit goes to this post on Stack Overflow. I don't fully understand the syntax, but it works.
echo "Before commented block"
: <<'END'
command 1 # Doesn't get executed
command 2 # Doesn't get executed
echo "After commented block"
Another commenter pointed out that the string 'END' does not have a specific meaning and any string can be used. In fact, it may be advantageous to use a different string that you know won't be present in your block of code. Much to my amusement, he suggested SNURFLE_BURGERS:
echo this is not executed
I'm torn as to which naming convention to adopt.


Popular Posts