read var
#!/bin/bash
echo -n "input 2 words:"
read var1 var2
echo $var1 $var2
echo "input:\c"
read var3
echo $var3
结果
aston@ubuntu:~/test$ ./pro1.sh
input 2 words:aa bb
aa bb
input:\c
cc
cc
发现 \c 没有起作用,将首行的bash改sh
#!/bin/sh
echo -n "input 2 words:"
read var1 var2
echo $var1 $var2
echo "input:\c"
read var3
echo $var3
结果
aston@ubuntu:~/test$ ./pro1.sh
input 2 words:aa bb
aa bb
input:cc
cc