Многострочный строковый литерал

Простые типы / Строки

name="line"

#a string in quotes may simply go on over several lines
twoLines="1. First $name
2. Second $name"

#a here-doc gives a command the text up to the END line;
#variables are expanded, a \ at the end of a line joins the lines
multilineString=$(cat <<END
    1. First $name
    2. Second \
$name
        3. Third $name
    4. Fourth "$name"
END
)

#with the quoted 'END' the text is taken as it is
rawString=$(cat <<'END'
    5. Fifth $name
END
)

echo "$twoLines"
echo "$multilineString"
echo "$rawString"
#prints:
#1. First line
#2. Second line
#    1. First line
#    2. Second line
#        3. Third line
#    4. Fourth "line"
#    5. Fifth $name