need few clarifications
Hi,
I need few clarifications in the requirements.
In the file, are we supposed to check only the lines that contains
"INFO Bonus required "
to the next line that contains
"INFO AIR credit operation success "???
If yes, we can go for a simpe script like
-----------------------------------------------------------------------
if [ $# -lt 1 ]
then
echo "Usage : " $0 "<file_name>"
exit 1
fi
echo "Going to scan the file : "$1
file_name=`echo $1`
prev_line=2
for cur_line in `cat $file_name | tr ' ' '+'`
do
echo $prev_line | grep "INFO+Bonus+required+" >test_file
if [[ -s test_file ]]
then
prev_msisdn=`echo $prev_line | tr ',' '+' | tr -s '+' | cut -d '+' -f 11`
cur_msisdn=`echo $cur_line | tr ']' '+' | tr -s '+' | cut -d '+' -f 13`
if [ "$prev_msisdn" -ne "$cur_msisdn" ]
then
echo "msisdn mismatch found"
echo "cur_msisdni : "$cur_msisdn
echo "prev_msisdn : "$prev_msisdn
fi
fi
prev_line=`echo $cur_line`
done
-----------------------------------------------------------------------
which works like
$> ./check_msisdn a
Going to scan the file : a
msisdn mismatch found
cur_msisdni : 113220
prev_msisdn : 13220
and the contents of file a were the same that you have provided except for a change in the line
------------------------------------------------------------
2008:07:08 07:03:20.656 (tid 4) INFO Bonus required [ msisdn = 13220, bonus = 18960, total usage = 189606 ]
2008:07:08 07:03:20.687 (tid 4) INFO AIR credit operation success [ msisdn = 113220]
---------------------------------------------------------------