如何在Bash中输出多行字符串? [英] How to output a multiline string in Bash?

查看:142
本文介绍了如何在Bash中输出多行字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I output a multipline string in Bash without using multiple echo calls like so:

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

我正在寻找一种仅使用Bash内置函数的便携式方法.

I'm looking for a portable way to do this, using only Bash builtins.

推荐答案

在此经常使用文档.

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

Report bugs to: 
up home page:
EOF

所有Bourne衍生的Shell(包括所有Bash版本)都支持它们.

They are supported in all Bourne-derived shells including all versions of Bash.

这篇关于如何在Bash中输出多行字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆