The echo command

The echo builtin command just repeats the arguments you provide it onto the standard output:

$ echo Hello
Hello

This makes it a simple way to emit content to the terminal, including variables:

$ echo 'Hello, '"$USER"\!
Hello, bashuser!

The echo command in Bash has switches that allow you to control the output, such as excluding the final newline, or expanding sequences such as \t to tab characters. However, we caution against using echo in scripts, because for historical reasons it has broken design and portability problems that makes it confusing or error-prone to use, especially when trying to use it with switches. We suggest you always use printf in scripts instead, as its behavior is more predictable, especially when ...

Get Bash Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.