How to split strings over multiple lines in Bash?

前端 未结 11 1182
[愿得一人]
[愿得一人] 2020-11-29 16:35

How can i split my long string constant over multiple lines?

I realize that you can do this:

echo "continuation \\
lines"
>continuation li         


        
11条回答
  •  星月不相逢
    2020-11-29 17:32

    However, if you have indented code, it doesn't work out so well:

        echo "continuation \
        lines"
    >continuation     lines
    

    Try with single quotes and concatenating the strings:

        echo 'continuation' \
        'lines'
    >continuation lines
    

    Note: the concatenation includes a whitespace.

提交回复
热议问题