1 TMOUT

来自bash的解释:

If set to a value greater than zero, TMOUT is treated as the

default timeout for the read builtin. The select command

terminates if input does not arrive after TMOUT seconds when

input is coming from a terminal. In an interactive shell,

the value is interpreted as the number of seconds to wait for

input after issuing the primary prompt. Bash terminates

after waiting for that number of seconds if input does not

arrive.



能够了解TMOUT能够非常好的read命令结合,在用户长时间没有输入时,能够通过TMOUT指定的时间来结束read的运行.

实例:

#!/bin/bash

TMOUT=4

echo -e "plesae input your name:"

read name

if [ -z $name ]
then
name="(no name provide)"
fi echo "Your name is : $name"
05-11 22:38