What is the function of echo -e in Linux?

In Linux, the echo -e command is used to output a string and can interpret special characters within the string. The -e option instructs the echo command to interpret special characters and convert them into corresponding control characters.

特殊字符包括:

  1. \n: newline character
  2. Tabulation character
  3. \b: backspace symbol
  4. \r: carriage return
  5. Backslash
  6. Single quotation mark
  7. quotation marks

When using the echo -e command, you can include special characters in the string, such as:

echo -e "Hello\nWorld"

Output:

Hello
World

Special characters will be treated as regular characters if the -e option is not used.

echo "Hello\nWorld"

Output:

Hello\nWorld
bannerAds