1、在if 判断语句中,当判断变量与字符串是否相等时,不能够使用-eq,要用“==”;
[root@liang-00 ~]# a="abc" [root@liang-00 ~]# if [ $a == "abc" ] ;then echo "OK"; fi OK [root@liang-00 ~]#
判断变量是否与数字相等时,要用-eq;
2、shell中if判断语句后可以用“()”的形式;
[root@liang-00 ~]# a=10 [root@liang-00 ~]# if ((a<11)) ;then echo "ook";fi ook [root@liang-00 ~]#
3、select语句;
select 命令 in 选项
do
**************
done
4、while按行读取数据
cat 1.txt| while read line;do echo $line;done
[root@liang-00 shell]# vim 1.txt [root@liang-00 shell]# cat 1.txt |while read line ;do echo $line ;done 11111111111111111111 22222222222222222222 33333333333333333333 44444444444444444444 [root@liang-00 shell]#