echo Command: Tutorial & Examples

Display a message or the value of a variable

The echo command is a Unix utility that displays a message or the value of a variable on the command line. It is often used in scripts to output messages or to generate input for other commands.

To use the echo command, you can simply type echo followed by the message you want to display. For example:

echo Hello, world!

This will output the message "Hello, world!" to the console.

You can also use the echo command to display the value of a variable by using the $ symbol followed by the variable name. For example:

x=10
echo The value of x is $x

This will output the message "The value of x is 10".

The echo command has several options that allow you to customize its behavior, such as suppressing the trailing newline (-n), enabling interpretation of backslash escape sequences, and enabling shell expansion of arguments. It is a simple but useful tool for displaying messages and values on the command line.

CleverUptime uses echo a lot in its script to format the data that is collected on your server and prepare it for uploading to our analytics backend.

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA