Now I want to grep 20131002 and if it finds pattern "20131002" it should scan lines below "20131002" and if it finds the word "Voice" that comes after grepping "20131002, than script print out all such occurrences in the file. Script Output would look like below.
If the very first line of the file has 20131002, and the very last line of the file has Voice, with no other hits inbetween -- is that a valid match? If not, why not?
No first line is not "20131002" and last line is not "Voice", script first grep 20131002 and than scan lines below as soon as it come across first "Voice" it prints and search for other such patterns by grepping "20131002" and than lines below it, to search "Voice". And than prints all such patterns found.
Yes, sorry for the confusion, let me put it in more simple way.
Example:
20130210132030
A
B
C
Banana
20130210142320
D
E
F
Mango
20130210154634
G
H
I
Apple
20130210163415
J
K
L
Mango
20130210171829
M
N
O
Apple
So my script first grep pattern "20130210" once found, it should scan line below and scan for Apple, if Apple is found it should print. Output would look like below
"20130210154634 Apple"
"20130210171829 Apple"
Apple is printed to its corresponding "20130210" only, which is unique.
But if grep pattern "20130210" once found and it scans lines below and finds "Banana" or "Mango" it should exit and search for other grep pattern "20130210" and scan lines below it, as soon as it finds the first "Apple" it should exit and find other such patterns.