echo - command used to display a line of text, message on screen and value of variables.
Syntax/Usage:-
echo [option] [string… variables….]
Examples:-
echo Hello..!!!!
echo “Hello Programmers…” //use quotations for string with blank spaces
Figure 1
echo $SHELL //will print the value of environment variable ‘SHELL’ i.e default shell of user
echo “Default shell of user is $SHELL”
Figure 2
echo “Default shell of user is” $SHELL
By default, echo displays text/string and places a newline character at the end of it.
-n
Avoids the trailing newline character
echo –n Hello
Figure 3
-e
Enables interpretation of backslash escaped sequences (like \n \t) in the string
echo –e “Hello\tProgrammers”
Figure 4
-E
(default)
Disables interpretation of backslash escaped sequences in the string
echo –E “Hello\tProgrammers”
Figure 5
\\
backslash
Figure 6
Here \\ has further escaped the special meaning of \n sequence
\b
Backspace
Figure 7
Here 3 backspaces have been introduced.
\c
Produce no further output
Figure 8
The further output Programmers and trailing newline has not been produced in above example
\n
New line
Figure 9
\t
Horizontal tab
Figure 10
\v
Vertical tab
Figure 11