Introduction

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 

	
Echo Command
		
		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”

	
Echo Command
		
		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.

Options under Echo Command

-n

Avoids the trailing newline character

echo –n  Hello
		
Echo Command with -n
		
		Figure 3
		

-e

Enables interpretation of backslash escaped sequences (like \n \t) in the string

echo –e “Hello\tProgrammers”
		
Echo Command with -e
		
		Figure 4
		

-E

(default)

Disables interpretation of backslash escaped sequences in the string

echo –E “Hello\tProgrammers”
		
Echo Command with -E
		
		Figure 5
		

\\

backslash

Echo Command with \\
		
		Figure 6
		

Here \\ has further escaped the special meaning of \n sequence

\b

Backspace

Echo Command with \b
		
		Figure 7
		

Here 3 backspaces have been introduced.

\c

Produce no further output

Echo Command with \c
		
		Figure 8
		

The further output Programmers and trailing newline has not been produced in above example

\n

New line

Echo Command with \n
		
		Figure 9
		

\t

Horizontal tab

Echo Command with \t
		
		Figure 10
		

\v

Vertical tab

Echo Command with \v
		
		Figure 11
		

Email Address

If you have any training enquiry then send mail at info@techaltum.com.