Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
509 views
in Technique[技术] by (71.8m points)

Echo newline in Bash prints literal

In Bash, tried this:

echo -e "Hello,
World!"

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

I'm using Ubuntu?11.04 (Natty Narwhal).

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could use printf instead:

printf "hello
world
"

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...