码迷,mamicode.com
首页 > 系统相关 > 详细

每天写点shell

时间:2016-12-06 09:23:05      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:bash   make   用户   comm   log   and   shel   class   welcome   

1、read基本读取

  1 #!/bin/bash
  2 #testing the read command
  3 
  4 echo -n "Enter you name:"   #echo -n 让用户直接在后面输入 
  5 read name  #
  6 echo "Hello $name, welcome to my program."
                                               

 执行:

# ./read.sh
Enter you name: wangtao
Hello wangtao, welcome to my program.

 

2、read -p (直接在read命令行指定提示符)

  1 #!/bin/bash
  2 #testing the read -p option
  3 read -p "Please enter your age: " age
  4 days=$[ $age * 365 ]
  5 echo "That makes you over $days days old!"

执行:

# ./age.sh
Please enter your age: 23
That makes you over 8395 days old!

 

每天写点shell

标签:bash   make   用户   comm   log   and   shel   class   welcome   

原文地址:http://www.cnblogs.com/wangtao1993/p/6136169.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!