echo 是一个常用的 shell 命令,用于在终端输出文本
echo "Hello, World!"输出变量:name="John"echo "Hello, $name!"输出换行:echo -e "Line 1\nLine 2"输出不换行:echo -n "Please enter your name: "read name输出文件内容:echo $(cat file.txt)输出颜色文本:echo -e "\033[31mRed text\033[0m"输出日期和时间:echo "Current date and time: $(date)"输出命令结果:echo "Your current working directory is: $(pwd)"输出带有特殊字符的文本:echo "This is a \$ sign."输出数组元素:array=("apple" "banana" "cherry")echo "${array[@]}"这些技巧可以帮助你更好地使用 echo 命令来完成各种任务。当然,还有更多关于 echo 的高级用法,但这里列出了一些基本的技巧。在编写 shell 脚本时,灵活运用这些技巧将大大提高你的工作效率。


