How do I add a line break for read command?

前端 未结 7 628
孤街浪徒
孤街浪徒 2020-12-24 10:43
 read -p \"Please Enter a Message:\" message

How can I add a line break after Message:?

相关标签:
7条回答
  • 2020-12-24 11:16

    From the bash manpage:

    -p prompt
       Display prompt on standard error, without a trailing new-
       line, before attempting to read any input.  The prompt is
       displayed only if input is coming from a terminal.
    

    So, not with read itself, and putting \n in the message string just echoes \n. The answer should be simple though - don't get read to display the prompt:

    echo "Please Enter a Message:" 1>&2
    read message
    
    0 讨论(0)
提交回复
热议问题