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 
相关推荐
DeeplyMind5 分钟前
第27章 常见问题与解决方案
运维·docker·容器
_OP_CHEN7 分钟前
【Linux系统编程】(三十六)深挖信号保存机制:未决、阻塞与信号集的底层实现全解析
linux·运维·操作系统·进程·c/c++·信号·信号保存
catoop8 分钟前
Nginx 解决 upstream sent too big header 错误
运维·nginx
laplace012310 分钟前
第二章 字符串和文本 下
服务器·数据库·python·mysql·agent
IvanCodes16 分钟前
六、Linux核心服务与包管理
linux
ayaya_mana20 分钟前
Linux一键部署Docker与镜像加速配置
linux·运维·docker
七夜zippoe32 分钟前
模拟与存根实战:unittest.mock深度使用指南
linux·服务器·数据库·python·模拟·高级摸您
市安36 分钟前
基于 Alpine 构建轻量 Nginx 错误页面 Docker 镜像
运维·nginx·docker·alpine
bitbot44 分钟前
Linux是什麼與如何學習
linux·运维·服务器
哈哈浩丶1 小时前
ATF (ARM Trusted Firmware) -2:完整启动流程(冷启动)
android·linux·arm开发·驱动开发