search

Home  >  Q&A  >  body text

linux - Why does the `echo -e "\n"` command output two blank lines when it has only one newline character?

Just like the title.

1

2

3

4

5

<code>root@localhost:~# echo -e "\n"

 

 

root@localhost:~#

</code>

高洛峰高洛峰2875 days ago1177

reply all(3)I'll reply

  • 某草草

    某草草2017-06-08 11:04:43

    By default echo will output a newline character. So adding the specified "n", a total of two will be output.

    -n Don’t automatically wrap the line at the end

    So you can pass echo -n to not output the default newline.

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-06-08 11:04:43

    1

    <code>echo</code>

    The principle is explained by the two classmates above. If the questioner needs to output a blank line, this is fine

    reply
    0
  • 为情所困

    为情所困2017-06-08 11:04:43

    Because the echo command itself appends a newline character to the output string by default, you can prevent this default behavior by adding an option -n:

    1

    <code>echo -ne "\n"</code>

    reply
    0
  • Cancelreply