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.
特殊字符包括:
- \n: newline character
- Tabulation character
- \b: backspace symbol
- \r: carriage return
- Backslash
- Single quotation mark
- 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