sh UsersInput.sh
与 相比,为什么会给出不同的输出bash UsersInput.sh
?
我的脚本如下:
#!/bin/bash
echo -n "Enter: ";
read usersinput;
echo "You entered, \"$usersinput\"";
重击
localhost:Bash henry$ bash UsersInput.sh
Enter: input
You entered, "input"
嘘
localhost:Bash henry$ sh UsersInput.sh
-n Enter:
input
You entered, "input"
为什么-n
第一个行为正确,而第二个行为不正确?这是什么原因,是否有解决方法?