Linux下shell脚本中的read命令
来源:互联网 发布:word2016破解知乎 编辑:程序博客网 时间:2024/05/16 15:05
read命令作用:
从标准输入中读取一行,并把输入行的每个字段的值指定给shell变量
参数:-a 后跟一个变量,该变量会被认为是个数组,然后给其赋值,默认是以空格为分割符。
-d 后面跟一个标志符,其实只有其后的第一个字符有用,作为结束的标志,会举例说 明。
-p 后面跟提示信息,即在输入前打印提示信息。
-e 在输入的时候可以时候命令补全功能。
-n 后跟一个数字,定义输入文本的长度,很实用。
-r 屏蔽,如果没有该选项,则作为一个转义字符,有的话 就是个正常的字符了。
-s 安静模式,在输入字符时不再屏幕上显示,例如login时输入密码。
-t 后面跟秒数,定义输入字符的等待时间。
-u 后面跟fd,从文件描述符中读入,该文件描述符可以是exec新开启的。
示例:
$ vi shell_0831.sh#!/bin/bashecho "**************************read command**************************"#read -p and -techo "----1.read -p and -t ----"read -t 20 -p "please enter your name:" nameecho $name#read -s -pecho "----2.read -s and -p----"read -s -p "please enter your pass:" passecho -e "\n"echo "your pass is $pass"#read -decho "----3.read -d----"read -d eecho "end as e"
运行脚本程序:
$ ./shell_0831.sh**************************read command**************************----1.read -p and -t ----please enter your name:jackjack----2.read -s and -p----please enter your pass:your pass is 123----3.read -d----abcdffffeend as e
1 0
- Linux下shell脚本中的read命令
- Linux下shell脚本中的eval命令
- linux下shell脚本read操作
- shell脚本中的read
- Linux下shell脚本export命令
- linux shell--read命令详解
- linux shell命令之read
- Linux脚本Shell命令
- Linux脚本Shell命令
- linux下shell中的set命令
- linux下shell脚本
- Linux Shell脚本字符串命令中的管道符处理
- linux 下shell脚本执行多个命令的方法
- Shell脚本学习与Linux下vim命令使用
- 【Linux】shell脚本下的命令代换` `和$() 以及eval
- MySQL在Linux下Shell脚本操作命令
- Linux Shell—— read命令
- Linux Shell—— read命令
- 在超级表格公司工作一天是怎样的体验?
- 懒虫小鑫
- Jenkins进阶系列之——05FTP publisher plugin插件
- android startActivityForResult()为什么立即执行
- 排序总结
- Linux下shell脚本中的read命令
- [leetcode] 310. Minimum Height Trees
- LIBSVM在Matlab下的使用
- 201406-201609 个人总结
- Vuejs——(4)v-if、v-for
- Jenkins进阶系列之——06FTP publisher plugin插件下载(支持绝对路径)
- 微信企业号第三方应用开发[前言]
- 学spring security前的知识回顾
- vs2008 2010 2013初次尝试配置protobuf