`
445822357
  • 浏览: 740791 次
文章分类
社区版块
存档分类
最新评论

shell下文本文件内指定位置字符串运算

 
阅读更多

需求:

————————————————————————————————

20120905 114000
skey version stype state dlgnum boneinfo
cdma 168 1 0 1 6299 IIN-CDMA-PPCOCSV1.08.03
pstn 102 1 0 1 0 IIN-SNDPV1.01.27
cdma 102 1 0 1 2320 IIN-SNDPV1.01.27
active dialog number in system:5724


20120905 135000
skey version stype state dlgnum boneinfo
cdma 168 1 0 1 4303 IIN-CDMA-PPCOCSV1.08.03
pstn 102 1 0 1 0 IIN-SNDPV1.01.27
cdma 102 1 0 1 1755 IIN-SNDPV1.01.27
active dialog number in system:4052

________________________________________________________

两次打印出来的日志,会话数差值变化幅度进行监控


if [ $#-ne 1 ] ; then

echo'useage:$0 [filename1]'

exit 1

fi

filename=$1

if [ ! -f$filename ] ;then

echo 'file ' $filename 'not found,pleasecheck the filename.'

exit 2;

fi

rowcount=`cat$filename|wc -l`

rownum1=`expr$rowcount - 4`

rownum2=`expr$rowcount - 11`

rowvalue1=`sed-n $rownum1'p' $filename`

rowvalue2=`sed-n $rownum2'p' $filename`

rowvalue1num=`exprsubstr "$rowvalue1" 47 5`

rowvalue2num=`exprsubstr "$rowvalue2" 47 5`

echorowvalue1=$rowvalue1

echorowvalue2=$rowvalue2

echorowvalue1num=$rowvalue1num

echorowvalue2num=$rowvalue2num

diff=`expr$rowvalue2num - $rowvalue1num`

echodiff=$diff

free=`expr$diff \* 100 / $rowvalue1num`

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics