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

原文地址:https://www.cnblogs.com/sea-stream/p/10083350.html