#!/bin/bash
#查找
function findit(){
if [ "$#" -lt 1 ] ; then #判断函数参数个数echo "$#"
echo "Usage: findit filename"
return 1
fi
for loop #遍历调用函数的参数
#注意:这里是遍历函数的参数个数 不是外面调用shell的函数个数 但是下面是$* 会将shell 参数赋值给findif函数参数,如果要给函数传入特殊的值,我们可以用下面的 read -p "Please input the times of print you want: " n; 详细见 while循环
find $HOME -name $loop -print
done
return 0
}
findit $* //参数单个最多0-9 如果是2为必须用{} 比如{11} {12}等
function LoopPrint()
{
count=0;
while [ $count -lt $1 ]; //while循环 变量加1
do
echo $count $loop; //$loop是一个全局变量 上面那个函数的最后的值
let ++count;
sleep 1;
done
return 0;
}
read -p "Please input the times of print you want: " n;
LoopPrint $n;