bash - 如何在 Bash 中输出多行字符串?

标签 bash

如何在 Bash 中输出多行字符串而不使用像这样的多个 echo 调用:

echo "usage: up [--level <n>| -n <levels>][--help][--version]"
echo 
echo "Report bugs to: "
echo "up home page: "

我正在寻找一种仅使用 Bash 内置函数的可移植方法。

最佳答案

这里的文档通常用于此目的。

cat << EOF
usage: up [--level <n>| -n <levels>][--help][--version]

Report bugs to: 
up home page:
EOF

所有 Bourne 派生的 shell 都支持它们,包括所有版本的 Bash。

关于bash - 如何在 Bash 中输出多行字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10969953/

相关文章:

python - 将 python 函数作为 bash 命令运行

linux - 如何使 find 和 printf 在 bash 脚本中工作

bash - 使用 awk 基于行和列减少几个大的制表符分隔矩阵

bash - 后跟条件控制运算符时在子 shell 中忽略 set -e

具有空变量的 Bash 算术扩展行为

linux - 使用输入重定向(stdin)取消设置日志名

python - 如何在 MacOS High Sierra 上修复 Home-brew 的权限

bash - 为什么 bash 会插入我没有要求的引号?

Bash:根据标志重定向到屏幕或/dev/null

regex - 在 bash 脚本中使用 sed