Way to create multiline comments in Bash?

后端 未结 8 535
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-04 04:59

I have recently started studying shell script and I\'d like to be able to comment out a set of lines in a shell script. I mean like it is in case of C/Java :



        
8条回答
  •  粉色の甜心
    2020-12-04 05:11

    Multiline comment in bash

    : <<'END_COMMENT'
    This is a heredoc (<<) redirected to a NOP command (:).
    The single quotes around END_COMMENT are important,
    because it disables variable resolving and command resolving
    within these lines.  Without the single-quotes around END_COMMENT,
    the following two $() `` commands would get executed:
    $(gibberish command)
    `rm -fr mydir`
    comment1
    comment2 
    comment3
    END_COMMENT
    

提交回复
热议问题