shellScript之一个脚本中多个函数

来源:互联网 发布:openstack 源码 编辑:程序博客网 时间:2024/05/19 17:23
#!/bin/bashshow_week(){    for day in monday tuesday wednesday thursday friday saturday sunday    doecho -n "$day "    doneecho ""}show_number(){    for (( integer = 1;integer <= 7;integer++ ))    doecho -n "$integer "    doneecho ""}show_square(){    i=0    until [[ "$i" -gt 7 ]]    dolet "square=i*i"echo " $i * $i = $square"let "i++"    doneecho ""}show_weekshow_numbershow_square

结果:

~/Note/test # ./31mutil_func.sh monday tuesday wednesday thursday friday saturday sunday 1 2 3 4 5 6 7  0 * 0 = 0 1 * 1 = 1 2 * 2 = 4 3 * 3 = 9 4 * 4 = 16 5 * 5 = 25 6 * 6 = 36 7 * 7 = 49