You are currently viewing Linux Commands – echo

Linux Commands – echo

Linux Commands – echo

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed cp command in Linux which is used to copy files and directories in Linux.

https://cloudaffaire.com/linux-commands-cp/

In this blog post, we will discuss echo command in Linux. the echo command is used to print each given STRING to standard output, with a space between each and a newline after the last one.

Linux Commands – echo

You can print in the standard output using echo command. The string that passed to echo can be without quotes, with single quotes or with double-quotes. Shell interprets the input string differently according to the string format passed.

By default, echo appends a newline after the output. But you can use echo -n option to suppress newline appending.

By default, echo does not escape the backslash escapes. But you can use echo -e option for interpretation of backslash escapes.

escape character meaning
\a alert (bell)
\b backspace
\c suppress further output
\e escape character
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\0nnn the character whose ASCII code is NNN (octal). NNN can be 0 to 3 octal digits
\xHH the eight-bit character whose value is HH (hexadecimal). HH can be one or two hex digits

 

Using echo -E option to explicitly suppress backslash-escape (echo default behavior).

You can redirect the output of echo command to a file using > and >> redirection operators.

You can perform command substitution in echo command.

You can perform parameter expansion in echo command.

You can perform parameter substitution in echo command.

You can also perform an arithmetic operation in echo command.

You can perform regular expression in echo.

Hope you have enjoyed this article. In the next blog post, we will discuss printf command in Linux.

 

Leave a Reply