输入超时
#!/bin/bash
if read -t 5 -p "please enter your name: " name
then
echo name is $name
else
echo
echo time is over.
fi
分支语句
#!/bin/bash
read -n1 -p "Do you wanna continue?[Y/N]:" answer
case $answer in
Y|y) echo
echo "yes";;
N|n) echo
echo "no"
exit;;
esac
echo "end..."
隐式输入
#!/bin/bash
read -s -p "enter password: " password
echo password is $password
逐行读取文件
#!/bin/bash
count=1
cat test | while read line
do
echo line $count: $line.
count=$[ $count + 1 ]
done