Hi, I have a file as follows
ABC_value1
..
..
MY_LINE
....
....
ABC_value2
...
..
MY_LINE
....
...
ABC_value3
...
...
MY_LINE
....
and so on. I want to search this file and output wherever MY_LINE occurs, prefixed by the ABC_ value that goes ahead of MY_LINE. There might be an ABC_valuei that might not have MY_LINE so I need to be able to search this file for all occurances of MY_LINE for all values of ABC_value.
How do I grep in this file so that it prints out ABC_valuei and MY_LINE, so that I can see in the output whether or not MY_LINE is defined for ABC_some value.
Example output:
ABC_value1
MY_LINE
ABC_value2
MY_LINE
ABC_value3
ABC_value4
ABC_valu5
MY_LINE
The above shows that MY_LINE is defined for ABC_ value1, valu2 and value5 but not value3 and value4. MY_LINE is a fixed string and ABC_value is variable, but always starts with ABC_.
Thanks a lot!
Sashi
ABC_value1
..
..
MY_LINE
....
....
ABC_value2
...
..
MY_LINE
....
...
ABC_value3
...
...
MY_LINE
....
and so on. I want to search this file and output wherever MY_LINE occurs, prefixed by the ABC_ value that goes ahead of MY_LINE. There might be an ABC_valuei that might not have MY_LINE so I need to be able to search this file for all occurances of MY_LINE for all values of ABC_value.
How do I grep in this file so that it prints out ABC_valuei and MY_LINE, so that I can see in the output whether or not MY_LINE is defined for ABC_some value.
Example output:
ABC_value1
MY_LINE
ABC_value2
MY_LINE
ABC_value3
ABC_value4
ABC_valu5
MY_LINE
The above shows that MY_LINE is defined for ABC_ value1, valu2 and value5 but not value3 and value4. MY_LINE is a fixed string and ABC_value is variable, but always starts with ABC_.
Thanks a lot!
Sashi