Uly.me

cloud engineer

  • Home
  • About
  • Archives
Home/Linux/Comment Multiple Lines in BASH

November 28, 2017

Comment Multiple Lines in BASH

If you find yourself commenting out multiple lines in BASH, there is a simple way of commenting them out using the HERE DOCUMENT feature. Typically you use the hash (#) tag to comment out each line, but that can get tiresome especially if have hundreds of lines. Here’s a better option. Use the HERE DOCUMENT feature in BASH. Anything in between the HERE DOCUMENT will be ignored by BASH and treated as comments.

#<<COMMENT - Remove the # sign to activate the HERE DOCUMENT
echo "1"
echo "3"
echo "4"
#COMMENT - Remove the # sign to activate the HERE DOCUMENT

#<<COMMENT - Remove the # sign to activate the HERE DOCUMENT echo "1" echo "3" echo "4" #COMMENT - Remove the # sign to activate the HERE DOCUMENT

If you need to reverse them, then just do the following. In this way, you only have to touch 2 lines instead of multiple lines.

Filed Under: Linux Tagged With: comment, here doc

Have content delivered to your mail. Subscribe below.

About Me

I'm Ulysses, Cloud Engineer at Cardinal Health based in Columbus. This blog is about Linux and Cloud technology. When off the grid, I enjoy riding the electric skateboard. I've surfed, snowboarded and played the saxophone in the past. I hope you will find this website helpful. It's powered by WordPress and hosted on AWS LightSail.

  • Cloud
  • Linux
  • Git

Copyright © 2012–2021