Ad space (banner)
🖥️Linux Lessons
Lesson 10 / 61

Displaying and Writing Text with echo

echo is for when "I want to display text in the terminal, and save it to a file." echo is a command that outputs the given string directly to the screen.

Use it in the form echo "string". Add >, like echo "string" > filename, and the output gets written into that file instead.

Running echo "My first note" > memo.txt doesn't display "My first note" on screen — instead, it gets written into a file called memo.txt.

A common early mistake is not realizing > completely overwrites an existing file's contents. To append instead, use >> (two of them).

In real work, this is used a lot for logging output inside shell scripts, or generating a simple config file.

Linux
Try it (type this into the pseudo terminal)
echo "My first note" > memo.txt

🧑‍💻 You can type this command into the Linux pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)