echo command in Linux with Examples


The echo command in Linux is a versatile tool used for printing text or variables to the terminal or redirecting them to a file. It is a simple yet powerful command that finds wide usage in shell scripting and day-to-day Linux operations.

In this tutorial, we will delve into the echo command, exploring its functionality and providing practical examples to illustrate its usage. echo command means Echo the STRING(s) to standard output.

echo command in Linux with Examples



On the man page, the describes it

  • echo – display a line of text.
  • man echo– More details information about echo command.

echo command in Linux with Examples

$ echo "Welcome to !"

Example 1: Printing a Message

echo "Hello, world!"

Example 2: Outputting Variable Values

echo "Name: $name"
echo "Age: $age"

Options and Flags

Example 3: Using the -n Flag

echo -n "This is "
echo "a single line."

Example 4: Using the -e Flag

echo -e "Line 1\nLine 2\tTabbed Line 3"

Example 5: Redirecting Output to a File

echo "This is some content." > output.txt

This command creates a file named output.txt and writes the text “This is some content.” into it.


echo command in Linux is a simple command in Linux. It is the most popular in-use terminal Linux displays a line of text. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.