The echo command is used to display a line of text on the terminal. We can also use the echo command to write text to a file by providing the string after the echo command and redirecting to the file.
echo Command Examples
1. To Prints the string on output device:
$ echo "Prints output"
Prints output
2. To skip printing the trailing new line:
$ echo -n "its remove the new line"
its remove the new line
3. To enable the interpretation of backslash escapes (****):
$echo -e "Test \a Operator"
Test Operator
The below operators are used with echo -e.
Operator- Interpretation
\\ -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)
4. To disable interpretation of backslash escapes:
$ echo -E "Hi\! There"
Comments (0)