第一个Unix Shell函数

2014-11-24 08:27:22 · 作者: · 浏览: 2

凡事都有个开头;有句话说,万事开头难;不管以后的路怎么样,走好脚下的每一步。


今天接触到了Unix shell中的函数,记录下,写了个hello函数,如下:


pg fun_hello.sh
#!/bin/ksh


hello () {
echo "Hello ,this is my first Shell function!"
echo "Today is `date +%Y-%m-%d\ %H:%S:%M\ %A`"
}
#Call hello function
hello
#EOF


执行脚本:


sh fun_hello.sh
Hello ,this is my first Shell function!
Today is 2013-02-01 15:48:25 Friday


--the end--