Files
my-docs/Linux/Bash Script/01-Echo.md
2025-08-03 00:47:45 +03:30

898 B
Raw Blame History

📌 Echo Basic Usage

echo Hello, world!

Output:

Hello, world!

💡 Common Use Cases

  1. Print plain text:

    echo This is a message
    
  2. Print environment variables (Linux/macOS):

    echo $HOME
    
  3. Print environment variables (Windows):

    echo %USERNAME%
    
  4. Write to a file:

    echo "Log entry" >> logfile.txt
    
  5. Suppress newline (Unix/Linux):

    echo -n "No newline"
    
  6. Use with escape characters (Unix/Linux):

    echo -e "Line1\nLine2"
    

⚠️ Notes

  • On Unix-like systems, echo is a shell builtin (e.g., in bash, sh).
  • On Windows, its a command in cmd.exe.
  • Behavior may vary slightly between environments. For complex text handling, consider using printf instead in Unix/Linux.