fi
done
fi
if [ ${mycheck} == 0 ]; then
echo "your may eat ${eat[${check}]}"
eated=$(( ${eated} + 1 ))
eatedcon[${eated}]=${check}
fi
done
透过随机数、数组、循环与条件判断,你可以做出很多很特别的东西!还不用写传统程序语言~试看
看~挺有趣的呦!
12.6 shell script
的追踪与
debug
scripts
在执行之前,最怕的就是出现语法错误的问题了!那么我们如何
debug
呢?有没有办法不需
要透过直½执行该
scripts
就可以来判断是否有问题呢?呵呵!当然是有的!我们就直½以
bash
相关参数来½行判断吧!
[dmtsai@study ~]$
sh [
-
nvx] scripts.sh
选项
参数
-
n
:不要
script
½
询语
法的
问题
-
v
:再
sccript
前,先
½
scripts
出到屏幕上;
-
x
½
使用到的
script
示到屏幕上,
是很有用的
参数
范例一:
测试
dir_perm.sh
无语
法的
问题
[dmtsai@study ~]$
sh
-
n dir_perm.sh
#
问题
会显
示任何信息!
范例二:
½
show_animal.sh
程全部列出
[dmtsai@study ~]$
sh
-
x show_animal.sh
+ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin
+ export PATH
+ for animal in dog cat elephant
+ echo 'There are dogs.... '
There are dogs....
+ for animal
in dog cat elephant
+ echo 'There are cats.... '
There are cats....
+ for animal in dog cat elephant
+ echo 'There are elephants.... '
There are elephants....