Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi there
I am hoping you could help me with a script that would search for a word and extract the block of text containing it.
This is a log file containing multiple messages.
I would like to first search for a keyword, ("bwSipRequestTimeOutReceived")and then extract the lines of text containing it. Each log is seperated by a blank line.See below as an example of lines of text of the messageany help with awk or similar command to acheive this would be greatly appreciated.
Thankyou very much3234049,1197578062818,1,0,false,
"bwSipRequestTimeOutReceived",
"as1",
"Application Server",
"SIP",
"SIP respond 408 Request Timeout received.
Response Message:
SIP/2.0 408 Request Timeout
Via:SIP/2.0/UDP 218.101.55.1:5060;received=218.101.55.1;branch=z9hG4bK-BroadWorks.218.101.55.1-218.101.55.201V5060-0-714830972-479130644-1197578053878-
Call-ID:BW093413878141207-1215374075@218.101.55.1
From:<sip:+xxxxxxx@218.101.55.1;user=phone>;tag=479130644-1197578053878-
To:<sip:011691yyyyyyyyy@csps.softswitch.ddddddd.net:5060;user=phone>;tag=2891-587c
CSeq:714830972 INVITE
Content-Length:0

i think this may work, but will need some manipulation.
FILE="path of log file"
SEARCH="\"bwSipRequestTimeOutReceived\""
cat $FILE | \
while read line
do
index1="`awk -v a="$line" -v b="$SEARCH" 'BEGIN{print index(a,b)}'` "
if [ index1 -ne 0 ] ;
then
echo $line
fi
done
Jain Sahab

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |