← Back to Bash Course | Chapter 1: Setup & Basics | Lesson 5 of 12

The echo Command

In this page:

  1. The echo Command

The echo Command

echo prints text to standard output, optionally followed by a newline. It supports flags like -n (no trailing newline) and -e (interpret backslash escapes like \n and \t). It's the most basic way to produce output from a script.

Note: Use echo -e when you need escape sequences like \n to actually create a new line.

Example: The echo Command

bash
#!/bin/bash
echo "Hello, Bash!"
echo -n "No newline after this"
echo ""
echo -e "Line1\nLine2\tTabbed"

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.