The syntax for the echo command is:
1. Input a line of text and display it on standard output
Outputs the following text:
2. Declare a variable and echo its value. For example, Declare a variable of x and assign its value=10.
echo its value:
Note: The ‘-e‘ option in Linux acts as an interpretation of escaped characters that are backslashed.
3. Using option ‘\b‘ – backspace with backslash interpretor ‘-e‘ which removes all the spaces in between.
4. Using option ‘\n‘ – New line with backspace interpretor ‘-e‘ treats new line from where it is used.
5. Using option ‘\t‘ – horizontal tab with backspace interpretor ‘-e‘ to have horizontal tab spaces.
6. How about using option new Line ‘\n‘ and horizontal tab ‘\t‘ simultaneously.
7. Using option ‘\v‘ – vertical tab with backspace interpretor ‘-e‘ to have vertical tab spaces.
8. How about using option new Line ‘\n‘ and vertical tab ‘\v‘ simultaneously.
Note: We can double the vertical tab, horizontal tab, and new line spacing using the option two times or as many times as required.
9. Using option ‘\r‘ – carriage return with backspace interpretor ‘-e‘ to have specified carriage return in output.
10. Using option ‘\c‘ – suppress trailing new line with backspace interpretor ‘-e‘ to continue without emitting new line.
11. Omit echoing trailing new line using the option ‘-n‘.
12. Using option ‘\a‘ – alert return with backspace interpretor ‘-e‘ to have the sound alert.
Note: Make sure to check the Volume key, before firing.
13. Print all the files/folders using echo command (ls command alternative).
14. Print files of a specific kind. For example, let’s assume you want to print all ‘.jpeg‘ files, use the following command.
15. The echo can be used with a redirect operator to output to a file and not standard output.
echo Options
| Options | Description |
| -n | do not print the trailing newline. |
| -e | enable interpretation of backslash escapes. |
| \b | backspace |
| \\ | backslash |
| \n | new line |
| \r | carriage return |
| \t | horizontal tab |
| \v | vertical tab |
That’s all for now and don’t forget to provide us with your valuable feedback in the comments below.
No comments:
Post a Comment