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]的情况,那种的需要好好考虑考虑才行
本文介绍了一个使用Shell脚本来处理特定文件模式的示例。该脚本通过grep命令查找指定的字符串模式并根据匹配情况执行相应的操作。具体而言,它会统计文件中符合特定模式的行数,并将符合条件的内容输出到不同的文件中。
2523

被折叠的 条评论
为什么被折叠?



