898 B
898 B
📌 Echo Basic Usage
echo Hello, world!
Output:
Hello, world!
💡 Common Use Cases
-
Print plain text:
echo This is a message -
Print environment variables (Linux/macOS):
echo $HOME -
Print environment variables (Windows):
echo %USERNAME% -
Write to a file:
echo "Log entry" >> logfile.txt -
Suppress newline (Unix/Linux):
echo -n "No newline" -
Use with escape characters (Unix/Linux):
echo -e "Line1\nLine2"
⚠️ Notes
- On Unix-like systems,
echois a shell builtin (e.g., inbash,sh). - On Windows, it’s a command in
cmd.exe. - Behavior may vary slightly between environments. For complex text handling, consider using
printfinstead in Unix/Linux.