shell 计时获取输入

 

#!/bin/bash
 
if read -t 5 -p "please enter your name:" name
 
then
 
    echo "hello $name ,welcome to my script"
 
else
 
    echo "sorry,too slow"
 
fi
 
exit 0

输出

please enter your name:xsxsxs
hello xsxsxs ,welcome to my script

 

posted @ 2018-12-07 15:48  anobscureretreat  阅读(302)  评论(0编辑  收藏  举报