How do I add a line break for read command?

2020-02-20 05:48发布

 read -p "Please Enter a Message:" message

How can I add a line break after Message:?

标签: bash shell unix
7条回答
叛逆
2楼-- · 2020-02-20 06:30

Here's an improvement on the accepted answer that doesn't require spawning a subshell:

read -p "Please Enter a Message:"$'\n' message

From the GNU Bash reference manual:

Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specified by the ANSI C standard.

查看更多
登录 后发表回答