dslreports logo
site
 
    All Forums Hot Topics Gallery
spc

spacer




how-to block ads


Search Topic:
uniqs
2
share rss forum feed


Black Box

join:2002-12-21

3 edits
reply to Brano

Re: grep (awk, sed) help

This looks like a job for awk. Here is my first crack at it, I bet it can be improved:

awk code:

#!/usr/bin/awk -f                                                             

BEGIN {
prev = ""
skip = "YES"
}

{
if (/mypattern/) {
skip = "YES"
} else {
if ("NO" == skip) {
print prev
}

prev = $0
skip = "NO"
}
}

END {
if ("NO" == skip) {
print prev
}
}