• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

cynchanpin

  • 博客园
  • 联系
  • 订阅
  • 管理

View Post

Linux shell 内部变量

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"

posted on 2017-06-20 19:10  cynchanpin  阅读(189)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3