linux shell之read
来源:互联网 发布:java打包war后如何发布 编辑:程序博客网 时间:2024/06/05 14:15
read常用几个选项
-n:read -n 2 var,将输入的字符串截取前2个字符放入到变量var中
root@ubuntu:~# read -n 2 var78root@ubuntu:~# echo ${var}78root@ubuntu:~#
-p:read -p “input your name:” name, -p后面是提示字符串,通过输入将值存取到name变量中
注意:“”提示字符串与name变量之间有空格,不然会出现另外情况
root@ubuntu:~# read -p "input your name:" nameinput your name:zhangsanroot@ubuntu:~# echo ${name}zhangsanroot@ubuntu:~#
-s:read -s var,将输入值存储到var中,但不在终端显示,不会显
#!/bin/bashread -p "input your DBName:" nameecho read -s -p "input your password:" passwordechoecho ${name}echo ${password}root@ubuntu:~/shell# ./no_echo.sh input your DBName:zhangsaninput your password:zhangsanabcd1234root@ubuntu:~/shell#
-t:read -t 3 var,在3秒内输入数据到var变量中,不然退出
-d:read -d “|” 使用“|”作为输入结束标志
root@ubuntu:~# read -d "|" varhello|root@ubuntu:~# root@ubuntu:~# echo ${var}helloroot@ubuntu:~#
一般-p、-t、-s可以结合使用
阅读全文
0 0
- linux shell之read
- linux shell命令之read
- Linux shell编程之read 命令
- linux shell中read
- shell 之 read
- Linux-shell编程之接收键盘输入read命令
- linux shell--read命令详解
- Linux shell read指令学习
- linux 之 read命令
- linux 之 read 用法
- Linux之read用法
- linux 命令之 read
- linux之read命令
- linux之read命令
- Linux shell编程中read参数说明
- linux下shell脚本read操作
- Linux Shell—— read命令
- Linux Shell—— read命令
- HTML5属性基础
- form表单按enter提交的问题
- Android遇到java.lang.RuntimeException: Binary XML file line
- 卷积模块演变史
- 源码编译安装YouCompleteMe步骤
- linux shell之read
- Spark之wordcount
- Hive配置 远程连接MySQL
- 算法:递归
- 二分查找(C语言描述)
- 孤儿进程与僵尸进程
- “软件工程(C编码实践篇)”实验报告【实验五:用callback增强链表模块来实现命令行菜单小程序V2.8】
- 桌面级3D打印机使用快速入门
- 模拟容器适配器栈和队列