tldr/pages.zh/common/echo.md

29 lines
668 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# echo
> 输出给定参数。
> 更多信息:<https://www.gnu.org/software/coreutils/echo>.
- 输出文本信息. 注意: 引号是可选的:
`echo "{{Hello World}}"`
- 输出带有环境变量的信息:
`echo "{{My path is $PATH}}"`
- 打印不带尾随换行符的信息:
`echo -n "{{Hello World}}"`
- 向文件添加信息:
`echo "{{Hello World}}" >> {{file.txt}}`
- 启用反斜杠转义的解释(特殊字符):
`echo -e "{{Column 1\tColumn 2}}"`
- 输出执行的上一条指令的退出状态(注:在 Windows 命令提示符和 PowerShell 中,对应的命令分别是 `echo %errorlevel%``$lastexitcode`
`echo $?`