0 总结
Get to the points first. The article comes from LawsonAbs!
updata on 2005:修改相关格式1.问题
使用shell
脚本判断字符串是否相等
基本要素
1)变量的声明2)if语句的使用3)echo的使用
2 .代码
#!/bin/bashstr1=lawsonstr2=lawsonAbsif [ $str1 = $str2 ] #注意这里的空格不能少!then echo equalelse echo not equalfi
代码的另一种表达,在if
语句中的两个变量中添加了“”符号。
#!/bin/bashstr1=liushenstr2=liutingif [ "$str1" = "$str2" ]then echo equalelse echo not equalfi