文/一介书生,一枚码农. scripts are for lazy people. 函数是存在内存里的一组代码的命名的元素.函数创建于脚本运行环境之中,并且可以执行. 函数的语法结构为: function <function-name> { <code to execute> } 创建函数不需要do或 done这些关键字,只需要大括号来界定函数的作用范围. 我们可以在命令行中创建一个简单的函数: function show_system { echo "The uptim
写在前面:案例.常用.归类.解释说明.(By Jim) 使用函数 #!/bin/bash # testing the script function myfun { echo "This is an example of a function" } count=1 while [ $count -le 5 ] do myfun count=$[ $count +1 ] done echo "This is the end of the loop" myfun ech
使用函数 #!/bin/bash # testing the script function myfun { echo "This is an example of a function" } count=1 while [ $count -le 5 ] do myfun count=$[ $count +1 ] done echo "This is the end of the loop" myfun echo "Now this is the end