Files
my-docs/Linux/Bash-Script/01-Echo.md

61 lines
898 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
### 📌 Echo Basic Usage
```bash
echo Hello, world!
```
**Output:**
```
Hello, world!
```
---
### 💡 Common Use Cases
1. **Print plain text:**
```bash
echo This is a message
```
2. **Print environment variables (Linux/macOS):**
```bash
echo $HOME
```
3. **Print environment variables (Windows):**
```cmd
echo %USERNAME%
```
4. **Write to a file:**
```bash
echo "Log entry" >> logfile.txt
```
5. **Suppress newline (Unix/Linux):**
```bash
echo -n "No newline"
```
6. **Use with escape characters (Unix/Linux):**
```bash
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.