文本处理CLI Manual
$echo
Print text strings or write data to files using shell redirection.
命令语法POSIX Standard
echo [OPTIONS] [STRING...]在交互式终端沙盒中实时运行
无需安装的客户端实时仿真环境。
bash — terminal
AST Sandbox (Free)
概述与工作原理
`echo` displays strings of text to standard output. When paired with `>` (overwrite) or `>>` (append) redirection operators, `echo` is the most common way to create config files, append environment variables, or print script debug statuses.
常用参数与选项说明
| Flag / Option | Description |
|---|---|
| -e | Enable interpretation of backslash escapes (e.g., \n for newline, \t for tab). |
| -n | Do not output the trailing newline character. |
实际生产案例与代码范例
#1Write text to a new file
echo "API_PORT=8080" > /home/user/.env && cat /home/user/.envCreates or overwrites .env with API_PORT=8080.
相关 Linux 常用命令
$grep文本处理
使用正则表达式或匹配字符串在文本文件与输出流中搜索内容。
$cat文件操作
连接文件并在终端标准输出上打印文件内容。
$touch文件操作
Create empty files or update file access and modification timestamps.
$head文本处理
Output the first part (top lines) of text files.
$tail文本处理
Output the last part (bottom lines) of files or stream real-time logs.
$wc文本处理
Print newline, word, and byte counts for files.