linux poison RSS
linux poison Email

Bash Script: Commenting out the block of code using here document

Many times it required to comment out the huge block of code for debugging purpose and it is very annoying to put the "#" tag before each and every line of this code

Below shell script shows how to comment out the block of code using here document (: <<'COMMENT')

Source: cat comment_block.sh
#!/bin/bash

echo "statement before comment."
: <<'COMMENT'
echo "This is inside the comment block and will not get printed"
a=0
b=20
echo $((b/a))
echo "No error"
COMMENT

echo "This is after the comment block."
exit

Output: ./comment_block.sh
statement before comment.
This is after the comment block.




0 comments:

Post a Comment

Related Posts with Thumbnails