How to specify a multi-line shell variable?

后端 未结 5 1415
陌清茗
陌清茗 2020-12-07 11:16

I have written a query:

function print_ui_hosts
{
local sql = \"select .........\"
print_sql \"$ sql\"
}

local sql - a very long string. Qu

5条回答
  •  青春惊慌失措
    2020-12-07 12:08

    I would like to give one additional answer, while the other ones will suffice in most cases.

    I wanted to write a string over multiple lines, but its contents needed to be single-line.

    sql="                       \
    SELECT c1, c2               \
    from Table1, ${TABLE2}      \
    where ...                   \
    "
    

    I am sorry if this if a bit off-topic (I did not need this for SQL). However, this post comes up among the first results when searching for multi-line shell variables and an additional answer seemed appropriate.

提交回复
热议问题