Block Comments in a Shell Script

后端 未结 12 1223
小鲜肉
小鲜肉 2020-12-02 03:36

Is there a simple way to comment out a block of code in a shell script?

12条回答
  •  生来不讨喜
    2020-12-02 04:05

    In bash:

    #!/bin/bash
    echo before comment
    : <<'END'
    bla bla
    blurfl
    END
    echo after comment
    

    The ' and ' around the END delimiter are important, otherwise things inside the block like for example $(command) will be parsed and executed.

    For an explanation, see this and this question.

提交回复
热议问题