按照我正在执行的 shell 脚本进行操作
#!/bin/sh
echo "Enter [y/n] : "
read opt
它的输出是
Enter [y/n] :
Y
我希望变量应该在下面的同一行中读取
Enter [y/n] : Y
我想应该很简单,但我是 bash 脚本的新手。
最佳答案
解决方法:read -p "Enter [y/n] :"opt
来自帮助阅读
:
-p prompt output the string PROMPT without a trailing newline before
attempting to read
关于linux - Shell 脚本,回显消息后在同一行读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9720168/