Linux Shell 编程基础详解——吐血整理,墙裂推荐! (7)

例: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 ]

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zydzpj.html