$linuxjunkies
>

echo(1)

Display a line of text or variables to standard output.

UbuntuDebianFedoraArch

Synopsis

echo [OPTION]... [STRING]...

Description

The echo command prints its arguments separated by spaces, followed by a newline. It's commonly used to display text, variable values, or create simple output in scripts.

By default, echo interprets backslash escape sequences only if the -e flag is used. Different shells and systems may have slightly different built-in behavior, so /bin/echo may behave differently from the shell's built-in.

Common options

FlagWhat it does
-nsuppress the trailing newline
-eenable interpretation of backslash escapes (\n, \t, \\, etc.)
-Eexplicitly disable interpretation of backslash escapes (default)

Examples

Print a simple string with a newline

echo "Hello, World!"

Display the value of the HOME environment variable

echo $HOME

Print without newline, then continue on the same line after a delay

echo -n "Loading..." && sleep 2 && echo " done!"

Print three lines using \n for newlines

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

Include script arguments in output

echo "Name: $1, Age: $2"

Print colored output using ANSI escape codes

echo -e "\033[1;32mGreen text\033[0m"

Use echo in a loop to print multiple lines

for i in {1..3}; do echo "Item $i"; done

Related commands