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
相關文章
相關標籤/搜索