例:vi error_file
#!/bin/sh set –x LIST="Peter Susan John Barry Lucy Norman Bill Leslie" echo -n "Enter your name :" read NAME for LOOP in $LIST do if [ "$LOOP" = "$NAME" ];then echo "you’re on the list, you’re in" break fi done set +x运行脚本
$ ./error_file执行结果:
error + error + LIST=Peter Susan John Barry Lucy Norman Bill Leslie + echo –n Enter your Name: Harry + [ Peter = Harry ] + [ Susan = Harry ] + [ John = Harry ] + [ Barry = Harry ] + [ Lucy = Harry ] + [ Norman = Harry ] + [ Bill = Harry ] + [ Leslie = Harry ]