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

后端 未结 3 1686
不知归路
不知归路 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:38

    It is called a Here Document. It is a code block that lets you send a list of commands to another command or program

    The string following the << is the marker determining the end of the block. If you send commands to no-op, nothing happens, which is why you can use it as a comment block.

提交回复
热议问题