Shell
跳到导航
跳到搜索
简介
什么是 shell
什么是 shell 脚本
Shell 环境
基本语法
解释器
注释
echo
echo 用于字符串的输出。
- 输出普通字符串:
echo "hello, world" # Output: hello, world
- 输出含变量的字符串:
name=xiaoming echo "hello, \"${name}\"" # Output: hello, "xiaoming"
- 输出含换行符的字符串:
# 输出含换行符的字符串 echo "YES\nNO" # Output: YES\nNO echo -e "YES\nNO" # -e 开启转义 # Output: # YES # NO
- 输出含不换行符的字符串:
echo "YES" echo "NO" # Output: # YES # NO echo -e "YES\c" # -e 开启转义 \c 不换行 echo "NO" # Output: # YESNO
- 输出重定向至文件:
echo "test" > test.txt
- 输出执行结果:
echo `pwd` # Output:(当前目录路径)