Table of Contents

Shell Data Processing - Echo (Gnu Utility)

About

This page is about the echo executable of the Gnu utility package that implements an echo functionality.

echo is also often implemented as a shell built-in command:

Syntax

To echo a string:

/bin/echo [OPTION]... [STRING]...

where:

backslash escapes

If -e is in effect, the following sequences are recognized:

This characters are control characters.

See the example interpretation of non visible characters

Location

The echo utility is found:

Management

Check if this is the gnu echo

In bash, with the type command, you can check if it's the echo bash builtin command and not GNU echo.

type echo
echo is a shell builtin

Example

Interpretation of non visible (\) characters

See Text - Control Characters

echo -e "hello Nico\nHello Nico"!
hello Nico
Hello Nico!

echo 'hello Nico\nHello Nico!'
hello Nico
Hello Nico!

trailing newline

By default, echo outputs along a newline character at the end. This behavior can be disabled with the -n options

Example within the bash shell:

for a in `seq 10`
do
  echo -n "$a "
done
1 2 3 4 5 6 7 8 9 10

for a in `seq 10`
do
  echo "$a "
done
1
2
3
4
5
6
7
8
9
10