• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

15 Practical Examples of ‘echo’ command in Linux

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
8
VIEWS
Share on FacebookShare on Twitter

Contents

  1. echo Options

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

15 Practical Examples of ‘echo’ command in Linux

echo command examples

The syntax for echo is:

echo [option(s)] [string(s)]

1. Input a line of text and display on standard output

$ echo Tecmint is a community of Linux Nerds 

Outputs the following text:

Tecmint is a community of Linux Nerds 

2. Declare a variable and echo its value. For example, Declare a variable of x and assign its value=10.

$ x=10

echo its value:

$ echo The value of variable x = $x 

The value of variable x = 10 

Note: The ‘-e‘ option in Linux acts as interpretation of escaped characters that are backslashed.

3. Using option ‘/b‘ – backspace with backslash interpretor ‘-e‘ which removes all the spaces in between.

$ echo -e "Tecmint /bis /ba /bcommunity /bof /bLinux /bNerds" 

TecmintisacommunityofLinuxNerds 

4. Using option ‘/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 ‘-e‘ to have horizontal tab spaces.

$ echo -e "Tecmint /tis /ta /tcommunity /tof /tLinux /tNerds" 

Tecmint 	is 	a 	community 	of 	Linux 	Nerds 

6. How about using option new Line ‘/n‘ and horizontal tab ‘/t‘ simultaneously.

$ echo -e "/n/tTecmint /n/tis /n/ta /n/tcommunity /n/tof /n/tLinux /n/tNerds" 

	Tecmint 
	is 
	a 
	community 
	of 
	Linux 
	Nerds 

7. Using option ‘/v‘ – vertical tab with backspace interpretor ‘-e‘ to have vertical tab spaces.

$ echo -e "/vTecmint /vis /va /vcommunity /vof /vLinux /vNerds" 

Tecmint 
        is 
           a 
             community 
                       of 
                          Linux 
                                Nerds 

8. How about using option new Line ‘/n‘ and vertical tab ‘/v‘ simultaneously.

$ echo -e "/n/vTecmint /n/vis /n/va /n/vcommunity /n/vof /n/vLinux /n/vNerds" 


Tecmint 

is 

a 

community 

of 

Linux 

Nerds 

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.

$ echo -e "Tecmint /ris a community of Linux Nerds" 

is a community of Linux Nerds 

10. Using option ‘/c‘ – suppress trailing new line with backspace interpretor ‘-e‘ to continue without emitting new line.

$ echo -e "Tecmint is a community /cof Linux Nerds" 

Tecmint is a community [email protected]:~$ 

11. Omit echoing trailing new line using option ‘-n‘.

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

12. Using option ‘/a‘ – alert return with backspace interpretor ‘-e‘ to have sound alert.

$ echo -e "Tecmint is a community of /aLinux Nerds" 
Tecmint is a community of Linux Nerds

Note: Make sure to check Volume key, before firing.

13. Print all the files/folder using echo command (ls command alternative).

$ echo * 

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.16.0-customkernel_1_amd64.deb network.jpeg 

14. Print files of a specific kind. For example, let’s assume you want to print all ‘.jpeg‘ files, use the following command.

$ echo *.jpeg 

network.jpeg 

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

$ echo "Test Page" > testpage 

## Check Content
[email protected]:~$ cat testpage 
Test Page 
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.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
Previous Post

How to Search DuckDuckGo from the Linux Terminal

Next Post

14 Useful Examples of Linux ‘sort’ Command – Part 1

Next Post

14 Useful Examples of Linux ‘sort’ Command – Part 1

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet