1

This question already has an answer here:

What does this mean?

echo -e \e

enter image description here

marked as duplicate by Thomas Dickey, Anthon, Eric Renouf, Archemar, thrig Apr 2 '17 at 14:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Try echo -e "\e[2J\e[2;4HRow two column four\n" It first clear screen and then go to row 2 and column four and write some text. – hschou Apr 1 '17 at 21:13
  • It means somebody wrote a script without paying attention to portability. On some systems (including one I use regularly) echo -e "hello\e" prints -e hello\e – Fox Apr 4 '17 at 16:25
1

What:

The -e flag for echo allows it to interpret certain sequences as having special meanings. For GNU echo those are:

\\ - backslash
\a - alert (BEL)
\b - backspace
\c - produce no further output
\e - escape
\f - form feed
\n - new line
\r - carriage return
\t - horizontal tab
\v - vertical tab
\0NNN - byte with octal value NNN (1 to 3 digits)
\xHH - byte with hexadecimal value HH (1 to 2 digits)

So these allow insertion of specific byte patterns into the text stream.

\e is hex value 0x1b also called escape. Not to be confused with escaping strings.

Why:

There are many reason you might need to insert specific bytes sequences into the stream. But one common reason is to allow communication with your terminal program. What are generally refered to as ansi escape codes. This is what the word escape refers in case of \e.

There is more explanation of this HERE.

Not the answer you're looking for? Browse other questions tagged or ask your own question.