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 
相关推荐
tntxia2 小时前
linux curl命令详解_curl详解
linux
扛枪的书生5 小时前
Linux 网络管理器用法速查
linux
SkyWalking中文站6 小时前
认识 Horizon UI · 1/17:SkyWalking 新一代可观测性控制台
运维·前端·监控
顺风尿一寸7 小时前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
雪梨酱QAQ9 小时前
Kubeneters HA Cluster部署
运维
江华森14 小时前
Spring Cloud 微服务全栈实战:从 Eureka 到 Docker Compose 一文贯通
运维
江华森14 小时前
Matplotlib 数据绘图基础入门
运维
XIAOHEZIcode14 小时前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
江华森14 小时前
NumPy 数值计算基础入门
运维
唐青枫16 小时前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux