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 
相关推荐
mounter6252 小时前
深入解析 RDMA 中的 Address Handler (AH) 缓存:AWS EFA 驱动的硬件演进与软件复用艺术
linux·kernel·rdma·hashtable·hash table·address handle
jarreyer8 小时前
【AI Agent】大模型自动化载体
运维·自动化
xixingzhe28 小时前
SpringBoot + Nginx 免鉴权接口安全防护方案
运维·nginx·安全
翼龙云_cloud9 小时前
阿里云国际代理商:阿里云 ECS 全维度监控配置教程
运维·阿里云·云计算·监控
笑锝没心没肺9 小时前
fail2ban工具安装配置及使用
linux·运维·服务器
zt1985q11 小时前
本地部署开源智能家居集成平台 ioBroker 并实现外部访问( Windows 版本)
运维·服务器·智能家居
大卡片11 小时前
linux内核驱动开发
linux·运维·驱动开发
心心喵12 小时前
[linux] nohup和pm2的区别 进程保活
linux·运维·服务器
NGINX开源社区13 小时前
F5 NGINX Ingress Controller 5.3.0 新增功能
运维
醉熏的石头13 小时前
Ubuntu 中的编程语言(中)
linux·ubuntu·scala