在击回声换行打印文字\\ n [英] Echo newline in Bash prints literal \n

查看:105
本文介绍了在击回声换行打印文字\\ n的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在bash中,尝试这样:

In Bash, tried this:

echo -e "hello\nworld"

不过,这并不打印一个换行符,只有 \\ n 。我怎样才能使它打印换行?

But it doesn't print a newline, only \n. How can I make it print the newline?

我在使用Ubuntu 11.04。

I'm using Ubuntu 11.04.

推荐答案

您可以使用的printf 而不是:

printf "hello\nworld\n"

的printf 拥有一致的行为不是回声的回声的行为不同版本之间的差异很大。

printf has more consistent behavior than echo. The behavior of echo varies greatly between different versions.

这篇关于在击回声换行打印文字\\ n的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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