首页 > 系统服务 > 详细

Shell的输入输出

时间:2015-07-05 14:58:09      阅读:156      评论:0      收藏:0      [点我收藏+]

通过使用read命令,可以实现从终端中输入内容后输出或执行运算

1 #!/bin/bash
2 #Author: blacksonny
3 #Copyright (c)
4 #Script follows here:
5 
6 echo "How old are you?"
7 read age
8 echo "age is " $age

以上代码会首先输出一个 [How old are yoy?],这时终端等待输入,当我们输入18这个数字(会将18赋值给age)并键入回车后,屏幕输出结果为age is 18

如下运行结果:

kk@kk-pc ~/shell
$ sh ./inout.sh
How old are you?
18
age is  18

Shell的输入输出

原文:http://www.cnblogs.com/blacksonny/p/4622077.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!