Shell学习_函数篇

上一篇 / 下一篇  2011-11-24 14:41:01 / 个人分类:shell

格式:

函数名()

{

命令

       …….

}

注:1、函数先定义后使用

   2、调用函数格式为:函数名参数

示例:#!/bin/sh

#the script. is to test the Fun

#author :zhuxiang

echo "Please enter the name:"

read name

Hello()

{

 echo "hello,zhuxiang$name"

}#定义函数

while [ $name -lt 10 ]

do

name=`expr $name + 1`

 Hello name#调用函数

done

echo "the student number is $name"


TAG:

 

评分:0

我来说两句

日历

« 2024-04-30  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 22210
  • 日志数: 31
  • 文件数: 1
  • 建立时间: 2010-08-18
  • 更新时间: 2011-12-01

RSS订阅

Open Toolbar