shell中使用read读取控制台的输入

一、语法

read (option) (parameter)

选项:

  • -p:读取值时的提示符
  • -t:读取值时等待的时间(秒)不加表示一直等待

参数:

  • 变量:指定读取值的变量名

二、例子

javascript 复制代码
[root@hadoop-master sh_test]# read_test.sh
input your number:666
your number is 666

#若超时,则跳过
[root@hadoop-master sh_test]# read_test.sh
input your number:your number is 
相关推荐
爱莉希雅&&&16 小时前
LVS+Keepalived+DNS+Web+NFS 高可用集群项目完整部署流程
运维·nginx·dns·lvs·keepalived·nfs·ipvsadm
小丑西瓜66616 小时前
CMake基础用法,cmake_minimum_required,project,add_executable
linux·服务器·c++·camke
晚风吹长发16 小时前
初步了解Linux中的命名管道及简单应用和简单日志
linux·运维·服务器·开发语言·数据结构·c++·算法
大熊背16 小时前
多核架构中,RTOS小核跑sensor 的normal模式,大核linux核跑WDR模式,将小核的曝光时间映射到WDR模式中的曝光时间的方法
linux·自动曝光·wdr
全栈测试笔记17 小时前
异步函数与异步生成器
linux·服务器·前端·数据库·python
weixin_4624462317 小时前
Linux 下使用 xfreerdp3 远程连接 Windows(从安装到实战使用)
linux·运维·windows
EndingCoder17 小时前
配置 tsconfig.json:高级选项
linux·前端·ubuntu·typescript·json
爱丶狸17 小时前
Linux三剑客之sed
linux·运维·服务器
China_Yanhy17 小时前
区块链运维日记 · 第 1 日 :消失的 2000 笔提现 —— 致命的 Nonce 冲突
运维·区块链
趁着年轻吃点苦18 小时前
录用通知-自助系统的服务器部署指南
运维·服务器