How to output a multiline string in Bash?

后端 未结 9 1769
忘了有多久
忘了有多久 2021-01-29 18:14

How can I output a multipline string in Bash without using multiple echo calls like so:

echo \"usage: up [--level | -n ][--help][--version         


        
9条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-29 18:56

    If you use the solution from @jorge and find that everything is on the same line, make sure you enclose the variable in quotes:

    echo $__usage
    

    will print everything on one line whereas

    echo "$__usage"
    

    will retain the newlines.

提交回复
热议问题