Commenting out a set of lines in a shell script

Vijay picture Vijay · Sep 18, 2009 · Viewed 132.8k times · Source

I was wondering if there is a way to comment out a set of lines in a shell script. How could I do that? We can use /* */ in other programming languages. This is most useful when I am converting/using/modifying another script and I want to keep the original lines instead of deleting.

It seems a cumbersome job to find and prefix # for all the lines which are not used.

Lets say there are 100 lines in the script in consequent lines which are not to used. I want to comment them all out in one go. Is that possible?

Answer

Artelius picture Artelius · Sep 18, 2009
if false
then

...code...

fi

false always returns false so this will always skip the code.