Some escape sequences perform different operations such as
Escape Sequences |
Meaning |
---|---|
\b | Backspace |
\\ | Backslash |
\n | New Line |
\r | Carriage Return |
\t | Horizontal Tab |
\v | Vertical Tab |
Example 1: Backspace
$ echo -e "Geeks \bFor \bGeeks"
Output:
w3wiki
Example 2: New Line
$ echo -e "Geeks\nFor\nGeeks"
Output :
Geeks
For
Geeks
Example 3: Horizontal Tab
$ echo -e "Geeks\tFor\tGeeks"
Output :
Geeks For Geeks
Example 4: Backslash
$ echo -e "Geeks\\For\\Geeks"
Output :
Geeks\For\Geeks
Example 5: Carriage Return
$ echo -e "Geeks\rFor Geeks"
Output :
For Geeks
Example 6: Vertical Tab
$ echo -e "Geeks\v For\v Geeks"
Output :
Geeks♂ For♂ Geeks
Example 7: -n Option
$ echo -n "Geeks For Geeks"
Output :
Geeks For Geeks
You can find all the commands related to echo by writing the following command.
$ /bin/echo --help
Output :
Bash Scripting – Bash Echo Command
In this article, we are going to see the echo command. The Echo command is a built-in command feature for Unix / Linux which is generally used to display the text or message on the screen.
Syntax :
$ echo [option]
For Example :
$ echo Geeks For Geeks
Output :
Geeks For Geeks
There are generally three options:
- -n: It does not print the trailing newline.
- -E: It is the default option that disables the implementation of escape sequences.
- -e: It is used to enable interpretation of backslash escapes