- 论坛徽章:
- 0
|
cat file
TotalLoad =96325 MinuteLoad =14 MsgDiscarded =0
UsrMsgDiscarded=0 SessionCount =1 MaxSessionCount=1
TimerCount =3 MaxTimerCount =4 SessionThreadIndex=0
0304 23:24:54.508 10305 OMAgent-8 Service statistics : ServiceName=NamingAgent
ModuleID =11 ThreadCount =1 ThreadIndex =3
TotalLoad =6 MinuteLoad =0 MsgDiscarded =0
UsrMsgDiscarded=0 SessionCount =0 MaxSessionCount=0
TimerCount =0 MaxTimerCount =0 SessionThreadIndex=0
0305 23:24:54.508 192631 OMAgent-8 Service statistics : ServiceName=LoadBalance
ModuleID =12 ThreadCount =1 ThreadIndex =9
TotalLoad =144479 MinuteLoad =21 MsgDiscarded =0
UsrMsgDiscarded=0 SessionCount =0 MaxSessionCount=0
TimerCount =2 MaxTimerCount =2 SessionThreadIndex=0
tdate="0305"
awk如何匹配shell变量为tdate0305开头的行,
即只匹配0305 23:24:54.508 192631 OMAgent-8 Service statistics : ServiceName=LoadBalance
而不匹配0304 23:24:54.508 10305 OMAgent-8 Service statistics : ServiceName=NamingAgent
awk -v date=$tdate '{if( $0 ~ date) print}' file
|
|