linux-tutorial/codes/shell/脚本函数/函数基本示例.sh

18 lines
263 B
Bash
Raw Normal View History

2019-10-29 18:22:19 +08:00
#!/usr/bin/env bash
2019-05-10 11:17:57 +08:00
# using a function in script
function func1 {
2019-10-29 18:22:19 +08:00
echo "This is an example of a function"
2019-05-10 11:17:57 +08:00
}
count=1
while [ $count -le 5 ]
do
2019-10-29 18:22:19 +08:00
func1
count=$[ $count + 1 ]
2019-05-10 11:17:57 +08:00
done
echo "This is the end of the loop"
func1
echo "Now this is the end of the script"