045-啤酒脚本

题目:一箱啤酒12瓶,你须要多少箱?而且显示出来?

给出两种方法
[root@cnsz142728 scripts]# ./Beer.sh 
12 bottles of beer in a box
How many box do you want:3
36 bottle in total 
[root@cnsz142728 scripts]# cat Beer.sh 
#!/bin/bash
declare N
echo "12 bottles of beer in a box"
echo -n "How many box do you want:"
read N

echo "$((N*12)) bottle in total "
[root@cnsz142728 scripts]# cat pp.sh 
#!/bin/bash
read -p "How many box do you want:" pp

echo "$(($pp*12))  bottle in total"
[root@cnsz142728 scripts]# ./pp.sh 
How many box do you want:5
60  bottle in total
[root@cnsz142728 scripts]# ./Beer.sh 
12 bottles of beer in a box
How many box do you want:6
72 bottle in total
相关文章
相关标签/搜索