Hi
I have a file consists of the following similar lines (10 mb file)
2008-05-15 02:15:38,268 [DEBUG] [AQUEDUCT-WebContainer : 3] RMSConnectionFactory - Setting session state for connection.
2008-05-15 02:15:38,277 [DEBUG] [AQUEDUCT-WebContainer : 3] RMSConnectionFactory - Returning WS connection.
My task is to find out any missing second lines for corresponding first lines.
I have written a script using bash, perl and awk commands but it takes lot of time to complete it. is there a better way to do this task ?
here is my current script:
#FILE contains a list of connection and return statements
FILE=summary_db_conn.txt
#DUP_FILE : Copying as another file so that i can do a loop to find out the missing return statements
DUP_FILE=summary_db_conn_dup.txt
#FINAL_FILE = file contains setting session records which don't have corresponding return statements
FINAL_FILE=final_not_matching_records.txt
# To see whether set connection statements have corresponding return connection statements
while read line; do
temp_output=`echo $line | grep "Setting session state for connection" | awk '{ print $1, $2, $4, $5, $6, $7 }' | perl -wn -e 'print "$1\n" if m{[\[](.*?)[\]]};'`
if [ "$temp_output" != "" ]; then
echo "$line :Processing line "
get_time=`echo $line | grep "Setting session state for connection" | awk '{ print $1,$2 }'`
#echo "get_time $get_time"
flag="0"
while read file_line; do
#echo "Match line : $file_line"
if [ "$flag" = "1" ]; then
temp\_file_output1=\`echo $file_line | grep "Returning WS connection" | awk '\{ print $1, $2, $4, $5, $6, $7 \}' | perl -wn -e 'print "$1\\n" if m\{[\\[]\(.*?\)[\\]]\};'\`
if [ "$temp\_file_output1" != "" ]; then
if [ "$temp_output" = "$temp\_file_output1" ]; then
\# echo "Found the matching return statement"
echo "$file_line"
echo "Break: Success"
break
fi
else
temp\_file_output1=\`echo $file_line | grep "Setting session state for connection" | awk '\{ print $1, $2, $4, $5, $6, $7 \}' | perl -wn -e 'print "$1\\n" if m\{[\\[]\(.*?\)[\\]]\};'\`
if [ "$temp\_file_output1" != "" ]; then
if [ "$temp_output" = "$temp\_file_output1" ]; then
echo $line >> $FINAL_FILE
\#echo "Searching for:$line"
echo "Sorry found another session start statement with the same thread $line"
echo "The new Line is:$file_line"
break
fi
fi
fi
fi
temp\_file_output=\`echo $file_line | grep "$get_time"\`
if [ "$temp\_file_output" != "" ]; then
\#echo "Found line"
\#echo "$file_line"
flag="1"
fi
done < $DUP_FILE
fi
done < $FILE
echo "Program Ended`date`" >> $FINAL_FILE
Please let me know is there a fast and better way of doing this task ....
Thanks