shell处理

来源:互联网 发布:java递归用乌龟画属性 编辑:程序博客网 时间:2024/06/05 10:02

cout=0
while read line
do i=grep -c "/[aaa/]/[s/]" $line;
if [ $i -eq 1 ]
then  
   flg="echo $i";
   cout=`expr $cout +1`; #每次遇到查出[aaa][s]开始计一次,加法写的不一定对
fi

if [ $flg -eq 1 ]
then
   j=grep -c "/[aaa/]/[e/]" $line;
   if [ $j -lt 1 ]
   then
       echo $line >> re$cout.txt;
   else
       if [ $i -lt 1 ] #或者判断条件是不等于1
       then
       echo $line >> re$cout.txt;      
       flg="echo 0";   #重新将flg置0
       fi
   fi
fi
done < wenjian.txt

#只能处理
#  -----[aaa][s]
#  ----------
#  ----------
#  ----------
#  -----[aaa][e]
#不能处理[aaa][s]内部在嵌套[aaa][s]的情况,那种的需要好好考虑考虑才行