Experts,
Hi there.
Feel like kicking myself today as I wish I could have paid more attention to learning while I was in college. If only wishes were horses ....
Anyway, Im parsing the contents of a log file.
Now what I need to do here is search for a pattern and then Pick the top 3 occurrences of lets say each one of the TEXT"s for example "PROVISIONED, AVAILABLE, EARL SIGNO and then list the corresponding 10 occurrences of it.
So, here is what Im doing
cat $LOGFILE | grep 'Deleting Text' | cut -d \" -f2 | more
� but this is only giving me text as below.
PROVISIONED
LOGGED NOR
EARL SIGNO
TURNED OFF
AVAILABLE
What Im looking for is as follows -
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Deleting Text on line 124 (ESN: 665367B8760830) because the number wasnt "PROVISIONED" and is not found in the database
Deleting Text on line 2474 (ESN: 607765B8577434) because the number wasnt "PROVISIONED" and is not found in the database
Deleting Text on line 2474 (ESN: 877765B8343429) because the number wasnt "PROVISIONED" and is not found in the database
Deleting Text on line 47764 (ESN: 3214567B8765430) because a number wasnt "AVAILABLE" and is not found in the database
Deleting Text on line 12400 (ESN: 7683567Z8776055) because a number wasnt "AVAILABLE" and is not found in the database
Deleting Text on line 12073 (ESN: 3213468Z4735412) because a number wasnt "AVAILABLE" and is not found in the database
Deleting Text on line 47764 (ESN: 5754567B8765430) because a number wasnt "TURNED ON" and is not found in the database
Deleting Text on line 12400 (ESN: 0334567B8765430) because a number wasnt "TURNED ON" and is not found in the database
Deleting Text on line 12073 (ESN: 8213467B8765430) because a number wasnt "TURNED ON" and is not found in the database
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please advise !
regards,
Lee
---------- Post updated at 09:42 PM ---------- Previous update was at 08:20 PM ----------
I guess, I did not make myself clear enough here.
Anyway, here is how far I could push this ...
cat $LOGFILE | grep -i 'Deleting Text' | cut -d'(' -f2 | sed -e 's/because a number wasnt //g' | sed -e 's/ because the number wasnt //g' | sed -e 's/and is not found in the database//g'
ESN: 607765B8577434) "PROVISIONED"
ESN: 877765B8343429) "PROVISIONED"
ESN: 3214567B8765430) "AVAILABLE"
ESN: 7683567Z8776055) "AVAILABLE"
ESN: 3213468Z4735412) "AVAILABLE"
ESN: 5754567B8765430) "TURNED ON"
ESN: 0334567B8765430) "TURNED ON"
ESN: 8213467B8765430) "TURNED ON"
Now, from the above lines, how do I get the following -
PROVISIONED - 607765B8577434
PROVISIONED - 877765B8343429
AVAILABLE - 3214567B8765430
AVAILABLE - 7683567Z8776055
AVAILABLE - 3213468Z4735412
TURNED ON - 5754567B8765430
TURNED ON - 0334567B8765430
TURNED ON - 8213467B8765430
Please advise.
regards,
Lee.