How does : <<'END' work in bash to create a multi-line comment block?

后端 未结 3 1782
不知归路
不知归路 2021-01-31 00:14

I found a great answer for how to comment in bash script (by @sunny256):

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


        
3条回答
  •  爱一瞬间的悲伤
    2021-01-31 00:42

    That's heredoc syntax. It's a way of defining multi-line string literals.

    As the answer at your link explains, the single quotes around the END disables interpolation, similar to the way single-quoted strings disable interpolation in regular bash strings.

提交回复
热议问题