shell編程學習之函數
1、創建函數和使用函數
-bash-3.2# cat test.sh
#!/bin/bash
hello ()
{
i=1
until [ $i -gt 5 ]
do
echo $i
let i++
done
}
hello
-bash-3.2# sh test.sh
1
2
3
4
5
2、反回值
#!/bin/bash
hello ()
{
i=1
until [ $i -gt 5 ]
do
echo $i
let i++
done
}
hello
echo $?
-bash-3.2# sh test.sh
1
2
3
4
5
0