Newlines and control characters

suggest change

A newline can be included in a single-string or double-quoted string. Note that backslash-newline does not result in a newline, the line break is ignored.

newline1='
'
newline2="
"
newline3=$'\n'
empty=\

echo "Line${newline1}break"
echo "Line${newline2}break"
echo "Line${newline3}break"
echo "No line break${empty} here"

Inside dollar-quote strings, backslash-letter or backslash-octal can be used to insert control characters, like in many other programming languages.

echo $'Tab: [\t]'
echo $'Tab again: [\009]'
echo $'Form feed: [\f]'
echo $'Line\nbreak'

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents