CentOS Debian Mint openSUSE Red Hat Ubuntu

Echo command in Linux

Echo-command-in-Linux

Introduction

The echo command is a useful choice for writing text in a terminal window. Its main task is to display text or string but not necessarily static text.

This command is available and is commonly used in shell scripts and batch files. And it is often used to output the results of other commands.

Here we will show you how to use the echo command in Linux as we did below. Hope you understand.

The syntax

The syntax:

$ echo [option] [string]

To display a text or string:

$ echo [string]

For example:

$ echo "Hello"

Output:

Options

1. \b remove all spaces

Example:

$ echo -e "Hello \bWorld"

Output:

You must use -e for the command to understand the meaning of “\”

2. \c remove the line after the option

Example:

$ echo -e "Hello \cWorld"

Output:

3. \n split newline

Example:

$ echo -e "Hello \nWorld"

Output:

4. \t separated by horizontal tab

Example:

$ echo -e "Hello \tWorld"

Output:

5. \r remove the line before the option

Example:

$ echo -e "Hello \rWorld"

Output:

6. \v separated by vertical tab

Example:

$ echo -e "Hello \vWorld"

Output:

7. echo* list all files/folders

Example:

$ echo *

Output:

Conclusion

We have shown you how to use echo command in Linux.

Thanks for referring!

Similar Posts