Linux echo Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux echo Guide
Complete beginner-friendly guide to echo on Linux, covering Arch Linux, CachyOS, and other distributions including text output, variable display, and shell scripting.
Table of Contents
Understanding echo
What is echo?
echo displays text.
Uses:
- Print text: Display messages
- Show variables: Display variable values
- Scripts: Output in scripts
- Debugging: Print debug messages
Why it matters:
- Scripting: Essential for scripts
- Debugging: Print values
- Output: Display information
echo Basics
Print Text
Display text:
# Print text
echo "Hello, World!"
# Or without quotes
echo Hello, World!
Print Variables
Show variables:
# Print variable
echo $HOME
# Or
echo "$HOME"
echo Options
No Newline
Same line:
# No newline
echo -n "Text"
# Continues on same line
Escape Sequences
Special characters:
# Enable escape sequences
echo -e "Line 1\nLine 2"
# \n: Newline
# \t: Tab
# \\: Backslash
Practical Examples
In Scripts
Script output:
#!/bin/bash
echo "Starting script..."
echo "User: $USER"
echo "Home: $HOME"
Debug Output
Debug messages:
# Debug output
echo "Debug: Variable value is $variable"
# Or with timestamp
echo "[$(date)] Debug message"
Troubleshooting
echo Not Found
Check installation:
# Check echo
which echo
# Usually built-in
# Or in coreutils
Summary
This guide covered echo usage, text output, and scripting for Arch Linux, CachyOS, and other distributions.
Next Steps
- Bash Scripting Guide - Scripting
- printf Guide - Formatted output
- echo Documentation:
man echo
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.