How Do You Know if Your Echo Is an Echo Plus

The echo command is one of the nigh usually and widely used congenital-in commands for Linux bash and C shells, that typically used in a scripting language and batch files to display a line of text/string on standard output or a file.

echo command
echo control examples

The syntax for the echo command is:

echo [option(due south)] [cord(due south)]        

ane. Input a line of text and display it on standard output

$ echo Tecmint is a community of Linux Nerds        

Outputs the following text:

Tecmint is a customs of Linux Nerds        

2. Declare a variable and repeat its value. For example, Declare a variable of ten and assign its value=10.

$ ten=x        

repeat its value:

$ echo The value of variable ten = $x   The value of variable x = 10        

Note: The '-eastward' option in Linux acts equally an interpretation of escaped characters that are backslashed.

iii. Using pick '\b' – backspace with backslash interpretor '-e' which removes all the spaces in between.

$ repeat -eastward "Tecmint \bis \ba \bcommunity \bof \bLinux \bNerds"   TecmintisacommunityofLinuxNerds        

4. Using selection '\n' – New line with backspace interpretor '-e' treats new line from where it is used.

$ echo -e "Tecmint \nis \na \ncommunity \nof \nLinux \nNerds"   Tecmint  is  a  community  of  Linux  Nerds        

5. Using option '\t' – horizontal tab with backspace interpretor '-east' to accept horizontal tab spaces.

$ repeat -eastward "Tecmint \tis \ta \tcommunity \tof \tLinux \tNerds"   Tecmint 	is 	a 	community 	of 	Linux 	Nerds        

6. How about using option new Line '\due north' and horizontal tab '\t' simultaneously.

$ echo -due east "\n\tTecmint \n\tis \n\ta \n\tcommunity \due north\tof \due north\tLinux \n\tNerds"   	Tecmint  	is  	a  	community  	of  	Linux  	Nerds        

7. Using option '\v' – vertical tab with backspace interpretor '-eastward' to take vertical tab spaces.

$ echo -east "\vTecmint \vis \va \vcommunity \vof \vLinux \vNerds"   Tecmint          is             a               community                         of                            Linux                                  Nerds        

viii. How about using option new Line '\northward' and vertical tab '\v' simultaneously.

$ echo -e "\due north\vTecmint \n\vis \northward\va \north\vcommunity \n\vof \n\vLinux \n\vNerds"    Tecmint   is   a   community   of   Linux   Nerds        

Note: We tin double the vertical tab, horizontal tab, and new line spacing using the option two times or as many times equally required.

9. Using option '\r' – wagon render with backspace interpretor '-eastward' to have specified carriage render in output.

$ repeat -e "Tecmint \ris a community of Linux Nerds"   is a community of Linux Nerds        

x. Using option '\c' – suppress trailing new line with backspace interpretor '-e' to go on without emitting new line.

$ echo -e "Tecmint is a community \cof Linux Nerds"   Tecmint is a community [email protected]:~$        

11. Omit echoing abaft new line using the option '-n'.

$ repeat -north "Tecmint is a community of Linux Nerds"  Tecmint is a community of Linux [email protected]:~/Documents$        

12. Using option '\a' – alert render with backspace interpretor '-e' to have the sound alert.

$ echo -eastward "Tecmint is a community of \aLinux Nerds"  Tecmint is a community of Linux Nerds        

Note: Make sure to bank check the Volume primal, earlier firing.

xiii. Print all the files/folders using echo command (ls control alternative).

$ repeat *   103.odt 103.pdf 104.odt 104.pdf 105.odt 105.pdf 106.odt 106.pdf  107.odt 107.pdf 108a.odt 108.odt 108.pdf 109.odt 109.pdf 110b.odt  110.odt 110.pdf 111.odt 111.pdf 112.odt 112.pdf 113.odt  linux-headers-3.16.0-customkernel_1_amd64.deb  linux-image-3.sixteen.0-customkernel_1_amd64.deb network.jpeg        

14. Print files of a specific kind. For example, let'south presume y'all want to print all '.jpeg' files, employ the following command.

$ echo *.jpeg   network.jpeg        

15. The echo can be used with a redirect operator to output to a file and not standard output.

$ echo "Exam Page" > testpage   ## Check Content [email protected]:~$ true cat testpage  Examination Page        
echo Options
 Options  Description
 -north  do not print the trailing newline.
 -eastward  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 usa with your valuable feedback in the comments below.

If You Appreciate What We Exercise Here On TecMint, You lot Should Consider:

TecMint is the fastest growing and well-nigh trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you lot like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never catastrophe support.

davisquareatunto.blogspot.com

Source: https://www.tecmint.com/echo-command-in-linux/

0 Response to "How Do You Know if Your Echo Is an Echo Plus"

Postar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel