How to specify a multi-line shell variable?

bash, shell

Solution

Use `read` with a heredoc as shown below:

read -d '' sql << EOF
select c1, c2 from foo
where c1='something'
EOF

echo "$sql"

Problem

I have written a query: ``` function print_ui_hosts { local sql = "select ........." print_sql "$ sql" } ``` local sql - a very long string. Query is not formatted. How can I split a string into multiple lines?

Original source

Related problems