linu下如何去读取一个变量呢?比如我们想定义一个变量,然后这个变量的值是用户输入的,当然了,这就是我理解的所谓交互性!
read 故名思议,就是读取的意思,
1 2 3 |
read name maple echo $maple |
第二行是我输入的,也就是说,我们可以把name的值设为任何我们输入的值,echo $name 输出的就是maple
当然这个read也是带提示符的,要不然平白无故肯定也不会知道要输入什么啊,所以我们可以这么写
1 2 3 |
read -p "Please input your name" name maple echo name |
今天先这些,得加班写代码了…..
原博客发表时间:2012-04-12 21:05:40
Latest posts by Zhiming Zhang (see all)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021