How to output a multiline string in Bash?

后端 未结 9 1630
忘了有多久
忘了有多久 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:49

    Also with indented source code you can use <<- (with a trailing dash) to ignore leading tabs (but not leading spaces).

    For example this:

    if [ some test ]; then
        cat <<- xx
            line1
            line2
    xx
    fi
    

    Outputs indented text without the leading whitespace:

    line1
    line2
    

提交回复
热议问题