Artificial intelligent assistant

Find a particular pattern in a text file and exclude them from output? I have a file that is around 25000 lines. Take a look at my sample input and required output INPUT: zone name tommy * pwwn xxxxxxxx pwwn xyzabcda * pwwn xcvuytnm zone name sammy * pwwn akslapsl * pwwn dfgsjasl * pwwn xcvuytnm zone name angelfalls * pwwn xxxxxxxx pwwn xyzabcda zone name Newyork * pwwn xxxxxxxx pwwn xyzabcda Desired Output: zone name tommy * pwwn xxxxxxxx pwwn xyzabcda * pwwn xcvuytnm zone name angelfalls * pwwn xxxxxxxx pwwn xyzabcda zone name Newyork * pwwn xxxxxxxx pwwn xyzabcda I want the output to exclude all the zones that contain a * in every line before the pwwn. In my example, zone name sammy has a * in all three pwwn lines, hence i excluded all * lines under zone name sammy. Using solaris 5.10, Korn Shell.

**`Awk`** solution:


awk '/^zone /{
if (f) print r;
r = $0; f = 0; next
}
{ r = r ORS $0; if (/^[^*]* pwwn/) f = 1; }
END{ if (f) print r }' file


The output:


zone name tommy
* pwwn xxxxxxxx
pwwn xyzabcda
* pwwn xcvuytnm
zone name angelfalls
* pwwn xxxxxxxx
pwwn xyzabcda
zone name Newyork
* pwwn xxxxxxxx
pwwn xyzabcda

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy ba165e9babb13218ee238d7f4ba6b97e